开发者

Is it appropriate to place a stylesheet within the <body> tag

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 l开发者_JAVA百科oaded unnecessarily.

In this case, is it appropriate to place a stylesheet within the <body> tag? Is there a better alternative?


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.


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.


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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜