- From: Mikko Rantalainen <mira@cc.jyu.fi>
- Date: Wed, 15 Jan 2003 21:04:48 +0200
- To: Richard Norman <normri@samc.com>
- CC: www-html@w3.org
Richard Norman wrote: [>Mikko Rantalainen wrote:] >> Please, *show* me a real world example where style attribute cannot be >> easily replaced with id + CSS and the situation isn't because of >> brain-dead administration. If administrator is too dumb to fix the Think about treating the symptoms instead of the cause. Think about *why* you need some piece of text underlined, bolded or italics. > My feeling is that style should be kept for certain elements for > individual styling of the elements. For example, if I had say three > different element areas. If I wanted one as underlined, one as > underlined and bolded and another as underlined and italics, That is > three different styles classes. If within those elements I wanted to > turn off the style, that is another style class (to turn off formatting > within the inline tag), if I then wanted to bold something within that, > then that is another class. > While ids could be used as well for specific instances, it is not good > to do that in my opinion because you would need to create a style for > each individual ID. And you should not duplicate Ids because the ID > uniquely identifies the tag. If you have duplicates, that will confuse > the DOM and also cause problems in scripting. So we have document like (I didn't check those CSS property names): ---- div.c1 { text-decoration: underline; } div.c2 { text-decoration: underline; font-weight: bolder; } div.c3 { text-decoration: underline; font-style: italic; } ---- <div class="c1"> blah <span style="text-decoration: none">blah <span style="font-weight: bolder">blah</span></span> blaa. </div> ... ... Surely there's some reason for that bolding, underlining or italics and undoing it. They are trying to represent some information and I feel that describing that piece of information through style attribute isn't the correct way to do that. If we remove the style attribute we can be sure nobody cannot even try to do that. In my opinion, the ID is used way too often and class should be often used instead. IMO, the correct way to do this is to put all the styles in external stylesheets, markup the content according to what it's trying to represent (closest semantic element plus a class if the match isn't close enough) and style those parts any way you feel. For example, the div.c1 above could be replaced with p.notice, div.c2 could be replaced with a em element enclosed in a p.imporant and div.c3 could be replaced with a blockquote (I'm just guessing what they could represent because the style cannot express it). The first part where you remove the underlining could be marked as small to represent the fact that it's less important piece of data (again, I guess the semantics) and the bolded piece inside that could be replaced with em element (I guess the target was to emphasize the word). Notice how you can understand part of the meaning of those fragments even though there weren't any author style to accompany that. And the styles look simple still: p.notice { text-decoration: underline; } p.notice small { text-decoration: none; font-weight: normal; font-size: normal; } p.notice em, em em { font-weight: bolder; } (I cannot come up with any better tag than small to represent "less important than the other stuff" and I'm too lazy to search for this.) -- Mikko
Received on Wednesday, 15 January 2003 14:04:16 UTC