linking .css to php document.

by 19 replies
22

















































#programming #css #document #linking #php
  • Did you include the line that includes the style sheet on the page?
    If so, what does it look like. If not, well...
    • [1] reply
  • I recommend you find an editor that will error check your PHP code before you put it on your server or upload it to the web. It will save you a lot of heartache. A decent free one is Netbeans.

    Also, I would recommend, always always ALWAYS "view source" in the browser, to see what is actually being output to the browser.
    • [1] reply
  • it's easy to print from PHP you just sometimes need to escape your characters (in this case you don't):

    <?php
    echo '<span class="blue">hello i'm blue</span>';
    ?>

    I hope that helps
  • In response to the OP (ronc0011) I Just wanted to give you another tip going forward that's best development practices, and that's to ALWAYS use the SAME kind of quotes (Either double or single) when you do output prints and echos, and learn the escape character which is a backslash (\).

    This doesn't work:

    <?php echo "<div class="Blue">hello</div>"; ?>

    But this does:

    <?php echo "<div class=\"Blue\">hello</div>"; ?>

    You see? You put the forward slashes in front of characters that don't go in strings and it displays them. You want to get in the habit of always using the same kind of quotes when you echo a string or you'll have to spend a lot of time thinking about it each time you go to make some outputs, and that can get tiring quickly!

    I could go really deep into this but the particular issue you have is resolved, so I wanted to leave this here as a bit of relevant advice you can use.
    • [ 1 ] Thanks
    • [1] reply
  • well most of times, i use like this

    <?php echo "<div class='Blue'>hello</div>"; ?>
    or
    <?php echo '<div class="Blue">hello</div>'; ?>

    both of these works, using mix of " and '.
  • You have given a really good example of integrating css into php. This will be very helpful to the new programmer and who want to build their carrier in the field of web development.

Next Topics on Trending Feed

  • 22

    So I've started tinkering with php and of course right from the beginning i'm having problems with the simplest things. I've installed WAMP Server so I've got a live Apache instance on my machine with the php interpreter running so i can run the pages I build So the first thing I'm trying to do is print to the screen html and I want to style it using CSS. I've got an external stylesheet site.css and so far I haven't' been able to get my text to pick up any of the styling from my style sheet In fact I haven't been able to find anything helpful on this topic. I've got Lynda.com and also VTC.com and n both cases they seem to be using depreciated HTML or styling. which I don't really care so much about except if I load the page or html in to VWD it gets flagged as depreciated code. So I prefer to use VWD (Visual Web Developer) to create any file except php files. I find it to be a much better coding environment. End result is I'm building my CSS file in VWD so all my styling rules are in my file site.css