W3C home > Mailing lists > Public > public-html-comments@w3.org > April 2010

RE: Alternate syntax for defining class attribute

From: Musgrove, Jason L <J.L.Musgrove2@wlv.ac.uk>
Date: Fri, 9 Apr 2010 22:05:00 +0100
Message-ID: <D7C66F5492F56948BC9244768A3283660DA7C517@exchange03.unv.wlv.ac.uk>
To: "T.J. Crowder" <tj@crowdersoftware.com>
Cc: <public-html-comments@w3.org>
I cannot see significant value in this proposal; having written a
considerable number of HTML documents and web applications, I cannot say
I have seen the class attribute as a problem. However, even if I did see
it a problem, this particular solution does, I believe, have a number of
issues:

 

Firstly, I'm not sure the syntax is valid SGML or XML - the two
serializations that HTML5 supports (I'm assuming the "HTML"
serialization is based upon SGML, like HTML 4 was).

 

Secondly, there would be a significant problem with
backwards-compatibility. I've just tried using one of these "hybrid"
tags in Firefox 3.6, and IE8 - neither of them recognised "<h1.test>" as
a "<h1>" tag - possibly making documents using them completely
unreadable in current browsers (and to anyone who thinks this is
unimportant as "everybody will have the latest browser installed" - I
know of many institutions, including my own employer, that still has IE6
on the desktop).

 

Thirdly, there's the mixing of semantics and presentation - something
that the CSS aimed to separate. The tag's name (which, as far as I
understand, is every valid identifier character up to the first
whitespace, or the end of the tag, whichever comes first) defines its
purpose, not its presentation.

 

Finally, a further thought on tag names: the element's start and end
tags are, I believe, required to have the same name. Thus, a hybrid tag
would only save on typing only if a single class name was shorter than 7
characters.

 

<span.nifty>something</span.nifty>

 

Is 2 characters short of its "traditional format":  <span
class="nifty">something</span>

 

<span.embellished>something</span.embellished>

 

Is 4 characters longer than: <span class="embellished">something</span>

 

Jason L. Musgrove

Web Application Developer

University of Wolverhampton

 

 

From: public-html-comments-request@w3.org
[mailto:public-html-comments-request@w3.org] On Behalf Of T.J. Crowder
Sent: 07 April 2010 22:26
To: public-html-comments@w3.org
Subject: Re: Alternate syntax for defining class attribute

 

Hi all,

 

I'd like to re-raise the below. I was just doing something yet again
which (legitimately) involved a lot of elements with classes on them,
and it was just so painful to write. There was no structural solution,
it was the nature of the beast, lots of interspersed things requiring
their own styling.

 

Yes, it's not something that's going to happen soon (not in HTML5, I'd
say), but taking the long view, I want to put it on the table for 5.1,
5.2, 5.5, 6, whatever. It's a very natural, straightforward, simple,
concise approach, and yet with (I assert) minimal impact on any
well-written parser.

 

Recapping to save your reading through the below: The idea is to provide
an alternate means of specifying a class on elements, by using the CSS
syntax, e.g.:

 

    <span.nifty>thing</span>

 

equals

 

    <span class="nifty">thing</span>

 

That's the core idea. Saves eight characters (which is nice in an of
itself; I assert that's typically going to be 50% or more of the text
defining the class), but also unifies a bit with the CSS selector syntax
for an element with a class.

 

Potential extensions to the idea involve multiple classes:

 

    <span."nifty spiffy">thing</span>

 

...but I don't think that's necessary at all if it over-complicates
parsers.

 

Naturally if class is also specified (I can see this happening with some
tools), the result is a union:

 

    <span.nifty class="cool">thing</span>

 

equals

 

    <span class="nifty cool">thing</span>

 

Is this the right place to put this on the table, or if not, where would
I do so?

 

Thanks in advance,

--

T.J. Crowder

Independent Software Consultant

tj / crowder software / com

www.crowdersoftware.com

 

 

On 25 August 2009 04:28, Ian Hickson <ian@hixie.ch> wrote:

On Sat, 15 Aug 2009, T.J. Crowder wrote:
> >
> > We've looked at doing this before, but it has a very poor backwards-
> > compatibility story, unfortunately.
>
> Yes, again, I did make the point in my original post that using this
> shorthand form would very much be a "caveat author" (author beware)
> situation -- the effect in older UAs will not be as desired.  Very
much
> like the new tags.  I frankly wouldn't expect to get much use out of
> this new shorthand form for a good 3-4 years while compliance comes up
> -- but in 3-4 years, it would be quite nice to have, hence suggesting
it
> now.

I think it would take a lot longer than 4 years, but in the meantime
we'd
have quite an unfortunate situation with respect to some browsers having
very different results than others, etc.


> > It wouldn't be that hard to parse, but it would only save you a 5

> > keystrokes...
>
> Which is to say, frequently, half the total.  I think 50% gains are
> worth pursuing.  But even more so, the alignment with CSS syntax is
very
> attractive and natural.

I think what would be helpful would be to make a JS library that fakes
this (by searching for elements with attributes that start with "." and
adding them to the class="" attribute), and seeing if it gets adoption.
That would provide interesting information for future developers of
HTML.

--

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

 


-- 

Scanned by iCritical.
Received on Friday, 9 April 2010 21:05:42 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 1 June 2011 00:14:02 GMT