Reputation: 3448
Splitting my pages into parts (eg. header and content), I can't avoid placing links to external stylesheets within <body>
tags.
I don't want to place all styles in one big file or enclose all stylesheets within the <head>
tag because page-specific stylesheets shouldn't be loaded unnecessarily.
In this case, is it appropriate to place a stylesheet within the <body>
tag? Is there a better alternative?
Upvotes: 12
Views: 11434
Reputation: 685
Yes you can call in the body it will work but this is bad practice. Either you can used the inline CSS stuff for the header & rest will used the by link tag.
Upvotes: 0
Reputation: 4747
you shouldn't place styles within the body tag, but assuming you're using a server side script (PHP?) to link both header and content, why not write your own class to generate your pages; you could have a method that add styles to the header, and one that outputs the page for instance.
Upvotes: 5
Reputation: 2757
Maybe it's not recommended, but yes, it's possible and it's working in all modern browsers. You can place link
or inline style
tags inside body
.
Upvotes: 9
Reputation: 5561
Why can't you have several stylesheets and then call them from the pages as needed?
Furthermore, why can't the stylesheets be referenced in the header as opposed to the body?
Upvotes: 0