Inline CSS should not be allowed in strict doctypes
As many of my readers already know all pages should include a doctype. The doctype tells the browser (or other user agent) what kind of document it can expect and what standards it follows.
You can divide doctypes into two categories. The first category consist of the transitional ones, the ones that allow old syntax and still validate, and the other one consist of the strict ones. I have repeatedly recommended the strict versions for a simple reason: it’s the best ones for separating design from content.
Just to show an example, transitional allows the following:
<body bgcolor="blue">
<center>
Strict, by its very nature, requires the use of CSS instead.
What I find strange is that inline CSS is valid in strict. Inline CSS is when you use the style attribute to set design information inside of the HTML. As an example the two deprecated pieces of code above can be done with:
<body style="background: blue">
<div style="text-align: center">
How is that any better than the transitional versions? Inline CSS goes against all the logic involved in the idea of two distinct doctypes. Why should you want to include design information inside of a document that you just explicitly stated would separate the two?
I hear the obvious reply: “What if I load design info from a database? I need to use inline CSS then!”. To me, that sounds like a perfect case where you need to go transitional, if you can’t manage to separate the two - don’t.
Strict doctypes are for documents where the webmaster has taken the time to clearly separate the content from the design, not other hybrids.
- Emil Stenström
- 28 May, 2006, CSS, HTML
Feel free to leave a comment, or subscribe to my feed.
linkback
These people have linked to this article:
- 456 Berea Street 6 Jun, 2006
- Are inline styles bad? | ara pehlivanian—Web Standards, Web Culture, Web Everything.™ 6 Jun, 2006
- Why is the style attribute allowed in strict doctypes? 7 Jun, 2006
- Max Design - standards based web design, development and training » Blog Archive » Some links for light reading (23/6/06) 22 Jun, 2006
- About Web Designing » Blog Archive » Inline CSS should not be allowed in strict doctypes 7 Jul, 2006
- Esqueça o atributo style. Estilos inline em doctype strict são resquícios do câncer de um passado sem padrões. » Revolução Etc - Web Standards em uma casca de noz! 28 Aug, 2006
- Transparent PNGs and IE6 standalone - Friendly Bit 28 Apr, 2007
To get a link in this list: make sure your blogging software supports trackbacks or pingbacks and simply link to this article like this:
<a href="http://friendlybit.com/css/inline-css-should-not-be-allowed-in-strict-doctypes/">Inline CSS should not be allowed in strict doctypes</a>
You can also trackback by copying this link, and pasting it into a trackback field in your blogging tool.

