[whatwg] additional empty elements

Ian Hickson ian at hixie.ch
Tue Oct 30 14:42:09 PDT 2007

On Tue, 1 May 2007, Brenton Strine wrote:
> Say, for example, you have a website which has sections of content that 
> are indented variously. It would be easy to accomplish the different 
> styles using classes:
> <div class="firstgroup">This text isn't indented at all!</div>
> <div class="secondgroup">This text is indented a little.</div>
> <div class="thirdgroup">Lots of indentation.</div>
> <div class="firstgroup">No indentation here!</div>

In general you should try to avoid using markup like this, which is tied 
to the presentation, and instead use markup that describes the meaning of 
the document, and have stylesheets keyed to that.

> However, if I then wanted to add additional special styling to the first 
> and third div, (e.g.. a border and background color) it is less 
> graceful. I could add style attributes, but that would be wasteful if I 
> want to do this on a large scale. Multiple classes would be confusing.

I don't see why multiple classes would be confusing.

> A nice solution would be the addition of a few div tags. (e.g. <div2>, 
> <div3>, <div4> and <div5>.) Then you could do something like this:
> <style>
> div1 {text-indent:0px;}
> div2 {text-indent:10px;}
> div3 {text-indent:20px;}
> </style>
> Then:
> <div1>This text isn't indented at all!</div1>
> <div2>This text is indented a little.</div2>
> <div3>Lots of indentation.</div3>
> <div1>No indentation here!</div1>
> This is much more human-readable, and the addition of additional styles 
> is now elegant and easy with the use of classes.
> <div1 class="bluestyle">This text isn't indented at all!</div1>
> <div2>This text is indented a little.</div2>
> <div3 class="redstyle">Lots of indentation.</div3>
> <div1>No indentation here!</div1>

I'm not sure I agree that this is more elegant.

> I also think that it would simply be easier to write code if there were 
> a few extra non-semantic empty tags. HTML5 needs improvements that will 
> make people want to use it. Making it easier to code than HTML 4 will 
> ensure a quicker and wider acceptance.

The goal isn't wide acceptance, the goal is a higher quality language.

> I am okay with the unimaginative numbering of the extra elements, as it 
> would make it easy to have a lot of new elements. However, there are 
> countless possibilities: <section>, <chunk>, <partition>, <block>, 
> <enclosure>, <zone>, <figure>, <sector>, <quadrant> etc...

Well, we have <section> amd <figure> now, for sections and figures 

> Are there other people who have found themselves wishing for another 
> <span> or <div>-like tag?

Apparently not. :-)

On Tue, 1 May 2007, Alexey Feldgendler wrote:
> HTML is a language for markup meaningful by itself, not just as a hook 
> for CSS. <div2> doesn't mean anything.


On Tue, 1 May 2007, Jon Barnett wrote:
> If you're marking up stuff as a tree, the markup should probably look like a
> tree:
> <section id="tree">First group
> <div>Second Group
> <div>Third Group</div>
> </div>
> </section>
> if what you want it a tree, that structure is better, so the CSS would
> simply say:
> #tree, #tree div { margin-left: 5em; }
> If you want to style each level differently, that's still easy to do without
> making up class names:
> #tree { background: blue; }
> #tree > div { background: green; }
> #tree > div > div { background: yellow; }

Indeed. One could also use nested <ul>s for a tree.

On Tue, 1 May 2007, Brenton Strine wrote:
> That doesn't seem very practical to me. If all HTML tags imply some 
> meaning, then you are advocating the elimination of presentation, not 
> it's separation. If there weren't any CSS hooks, wouldn't people just 
> (incorrectly) use other tags, like <h1>? I think that CSS and HTML are 
> unbreakably connected.

You can hook CSS to the meaning, it doesn't have to be an explicit hook. 
For example, you can style your headings:

   h1 { color: blue; }

...and the first paragraph after a heading:

   h1 + p { text-indent: 2em; }

...and so on.

On Tue, 1 May 2007, Dan Dorman wrote:
> An HTML document ought to make semantic sense, without regard to 
> presentational information.  The very definition of the separation of 
> presentation from content is that the content should be authored without 
> regard to how it will appear.  That's not to say presentation is being 
> eliminated, however; presentation simply should not be a consideration 
> in how the content is authored.  Ideally, anyway.


> Indeed, one could say CSS is fundamentally dependent on HTML; the 
> reverse is not true.  Imagine a new technology came along to make HTML 
> pretty:  wouldn't it be nice if you didn't have to rewrite the HTML to 
> service this new technology?


> As to folks using incorrect tags, well, what you're proposing isn't 
> going to fix that.

Sadly true.

> I think the supposition that multiple class names are confusing is 
> flawed.  What's wrong with saying <div class="redtext indentmore"> 
> (besides the fact that you'd want more useful, informative class names 
> than "redtext" and "indentmore")?  By looking at it, someone could 
> readily tell it's got the properties of both "redtext" and "indentmore".  
> In my estimation, being able to combine classes is one of the more 
> powerful aspects of CSS.

I agree (modulo those class names being poor choices).

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list