Connecting Tech Pros Worldwide Forums | Help | Site Map

<style> in body?

Newbie
 
Join Date: Aug 2008
Posts: 22
#1: Sep 2 '08
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.  

eWish's Avatar
Moderator
 
Join Date: Jul 2007
Location: Arkansas
Posts: 900
#2: Sep 2 '08

re: <style> in body?


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
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,569
#3: Sep 2 '08

re: <style> in body?


Well, it's invalid so I don't know what other problems you may have. It definitely messes with the DOM.
Newbie
 
Join Date: Aug 2008
Posts: 22
#4: Sep 2 '08

re: <style> in body?


thanks to both for you for the heads-up

I went ahead and made all styles inline to avoid any unforeseen problems
Familiar Sight
 
Join Date: Jun 2008
Location: Sweden
Posts: 130
#5: Sep 2 '08

re: <style> in body?


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>
Newbie
 
Join Date: Aug 2008
Posts: 22
#6: Sep 3 '08

re: <style> in body?


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
Reply