Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 2nd, 2008, 12:54 AM
Newbie
 
Join Date: Aug 2008
Posts: 22
Default <style> in body?

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:


Code:
<html><head>
<link type="text/css" href="usual.css"
 rel="stylesheet">
</head><body>

stuff here

<style type="text/css">
#footer {
  color: #999900;
  font-family: "times new roman",times,serif;
  font-weight: bold;
  max-width: 600px;
}
link { color# 999900;  
}

</style>
<div id="footer">©2008<img align="middle" style="width: 172px; height: 55px; " src="logo.gif">
</div>
</body></html>
Reply
  #2  
Old September 2nd, 2008, 01:20 AM
eWish's Avatar
Moderator
 
Join Date: Jul 2007
Location: Arkansas
Posts: 815
Default

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
Reply
  #3  
Old September 2nd, 2008, 01:37 AM
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 4,586
Default

Well, it's invalid so I don't know what other problems you may have. It definitely messes with the DOM.
Reply
  #4  
Old September 2nd, 2008, 12:41 PM
Newbie
 
Join Date: Aug 2008
Posts: 22
Default

thanks to both for you for the heads-up

I went ahead and made all styles inline to avoid any unforeseen problems
Reply
  #5  
Old September 2nd, 2008, 04:12 PM
Member
 
Join Date: Jun 2008
Location: Sweden
Posts: 120
Default

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).

Code:
<html><head>
<link type="text/css" href="usual.css"
 rel="stylesheet">
<!-- Footer STYLE there ^^^ -->
</head><body>
<!-- stuff here -->
<div id="footer">©2008<img src="logo.gif">
</div>
</body></html>
Reply
  #6  
Old September 3rd, 2008, 03:38 AM
Newbie
 
Join Date: Aug 2008
Posts: 22
Default

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
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles