By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,711 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,711 IT Pros & Developers. It's quick & easy.

<style> in body?

P: 22
I have a footer in a separate file that gets included via PHP, and that has its own styles.

That means the footer's <style> is declared in the body, rather than as an element in <head>. Is there any problem with doing it that way?

My aim is simply to include "footer.php" and have it all turn out okay, without messing with anywhere else.

The HTML that is output by PHP is below:


Expand|Select|Wrap|Line Numbers
  1. <html><head>
  2. <link type="text/css" href="usual.css"
  3.  rel="stylesheet">
  4. </head><body>
  5.  
  6. stuff here
  7.  
  8. <style type="text/css">
  9. #footer {
  10.   color: #999900;
  11.   font-family: "times new roman",times,serif;
  12.   font-weight: bold;
  13.   max-width: 600px;
  14. }
  15. link { color# 999900;  
  16. }
  17.  
  18. </style>
  19. <div id="footer">2008<img align="middle" style="width: 172px; height: 55px; " src="logo.gif">
  20. </div>
  21. </body></html>
  22.  
Sep 1 '08 #1
Share this Question
Share on Google+
5 Replies


eWish
Expert 100+
P: 971
It can be done this way. However, it is not recommended. I would suggest that you include it in an external css file. Then import it so you will not have to bother with having it in the body.

--Kevin
Sep 2 '08 #2

drhowarddrfine
Expert 5K+
P: 7,435
Well, it's invalid so I don't know what other problems you may have. It definitely messes with the DOM.
Sep 2 '08 #3

P: 22
thanks to both for you for the heads-up

I went ahead and made all styles inline to avoid any unforeseen problems
Sep 2 '08 #4

100+
P: 125
I prefer having the footer css in the external css file and not inline in the footer included by php. Especially if the footer is used in many places.

You can then change the css in the css file and the footer in the footer file, separated as HTML/CSS is preferred to be.

I think it's better in some ways, one being because the css file get cashed on client side if used frequently, not inline css (donno how/if the footer.php is cashed, depends on how used I think, but it's pasted in on server side).

Expand|Select|Wrap|Line Numbers
  1. <html><head>
  2. <link type="text/css" href="usual.css"
  3.  rel="stylesheet">
  4. <!-- Footer STYLE there ^^^ -->
  5. </head><body>
  6. <!-- stuff here -->
  7. <div id="footer">2008<img src="logo.gif">
  8. </div>
  9. </body></html>
Sep 2 '08 #5

P: 22
I suppose my thinking is that the footer will never change. Knock on wood, right? :)

Also, I'd think that I get carried away with being minimalistic, since my background was as an assembler programmer... so I see inline styles as one less network GET. Maybe I should break that habit of thinking. :)

And yes, you're right that any include is opaque to the browser and the network, which only sees the output html
Sep 3 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.