Jump to content

Inline Stylesheet


knystrom18

Recommended Posts

So, stylesheets normally exist in the head element, the style tag, or in an inline attribute (style="margin:0;). What about this?

<div style="stylefile.css">

I wrote a quick test page, and it validates to XHTML 1 Strict, but the stylesheet linked in the head element takes precedence, and I don't see any styling from the other. It seems like this should work because of the validation, but it doesn't (for me at least.) Is this slow browser implementation, or something else?

Link to comment
Share on other sites

It's valid XHTML but that doesn't mean it's functional. Only CSS code can go in the style attribute. It's valid XHTML because the style attribute exists and it contains character data, but that doesn't mean that the CSS parser can make any sense of it. You need to use the <link> element to load external CSS files.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...