Head style

W

William Tasso

Greetings one and all

Another question from the class of: "I'm sure it's in the spec somewhere,
if only I could find/decypher it."

Whether linked or not, styles go in the <head> this much we know.

Why?

style blocks appear to have the desired effect when located in the <body>

Is it compulsory or desirable to place them in the <head>? If the latter,
what are there advantages?

happy to discuss why it is an issue if you think it's relevant.

Thanks
 
S

Steve Pugh

William Tasso said:
Another question from the class of: "I'm sure it's in the spec somewhere,
if only I could find/decypher it."

Whether linked or not, styles go in the <head> this much we know.

Why?

Because a <style> element is information about the document as a
whole, same as the <title> element or a <meta> element. This sort of
element goes in the head because that's what the head exists for. The
body on the other hand exists to contain the actual contents of the
page.
style blocks appear to have the desired effect when located in the <body>

Browsers support lots of bad coding to compensate for incompetent
authors. We all know that.
Is it compulsory or desirable to place them in the <head>? If the latter,
what are there advantages?

The most desirable place to put them is in an external stylesheet.
Imagine a long document with the <style> element at the end. The
document is entirely downloaded before the presentation can be applied
(okay so some browsers manage to do that anyway, the FOUC, with the
styles linked from the head). And what of there are multiple style
elements in the body. Should they apply to the whole document? just to
the container they are in? or from that piunt onwards?

Steve
 
W

William Tasso

Chris said:
http://www.w3.org/TR/html401/struct/links.html#edef-LINK
suggests that it is compulsory. Looking through the DTD confirms this
(<link> is in head.misc, which is allowed in <head> but not <body>)

ok - I'm happy to deliver it as a said:
Why is it an issue?

I'm building a component library and would like to deliver default styles
for the markup. The components are accessed with server side includes and I
have no control over their placement in the customer's page(s) - if there
are recommendations then I'll deliver them in the help text - I don't want
to lie or b/s but I'm trying to ensure trivial ease-of-use with minimum
support issues.

The styles are applied using specified classes and IDs and (should) only
apply to the items delivered by the component.

Many thanks
 
W

William Tasso

Steve said:
[style]
Is it compulsory or desirable to place them in the <head>? If the
latter, what are there advantages?

See other post in this thread to see why it's a potential issue.
The most desirable place to put them is in an external stylesheet.

ok, I can do that with the default style as long as the the author incudes
the component in the <head> then that is where I can deliver the link or
perhaps include the component right at the top of the document and make a
Imagine a long document with the <style> element at the end. The
document is entirely downloaded before the presentation can be applied
(okay so some browsers manage to do that anyway, the FOUC, with the
styles linked from the head). And what of there are multiple style
elements in the body. Should they apply to the whole document? just to
the container they are in? or from that piunt onwards?

Thanks - there shouldn't (huh) be multiple styles affecting the same markup
in this case but, of course, it's impossible to know for sure.
 
W

William Tasso

EightNineThree said:
I know nothing about ASP, but with PHP, I typically call the style
sheet as a variable in the template. Right now, my defining of that
variable is pretty primative, but there's nothing that says it can't
be completely dynamic in some way (perhaps defining the customer's
variables in a db or a flat file).

Can ASP do this sort of thing?

Yes - trivially ;o)

That's one of the methods I employ in my templates.

I'm not delivering a template in this instance, just a component to sit
inside the authors page. Components - in this case - are made up of HTML
(and data/content as appropriate) with classes and IDs so I can style them.
Could be controlled/delivered from an external source but at the moment I'm
just delivering a scripted interface - of course a skilled user may choose
to drive that interface from a db or somesuch. I'm aiming to get to the
position that the component works with minimal/no configuration but allows
as much customisation as necessary for those that want/need to play.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,812
Messages
2,569,694
Members
45,478
Latest member
dontilydondon

Latest Threads

Top