Attribute references

european bob bob at wolfwall.com
Sun Jan 9 14:00:25 EST 2005


On Sun, 2005-01-09 at 13:19 -0500, John Gruber wrote:
> So I took a step backward, and realized the better solution would be
> a single syntax for applying tag attributes.

General-purpose solutions always worry me :)

Out of interest, how many times do you think you would apply the same
attribute to a number of tags? I can think of class, plus perhaps some
"work around CSS not being universal" attrs (cellspacing="0" ;), and
that kind of thing, but I think the applicability it limited.

Applying it as a class is kind of useful, but overly verbose. Most other
situations, I would think that you would only want to apply attributes
to a specific tag. id, for example, is something you only want to apply
to a specific tag. Other attrs may also behave more like id than class -
cite, lang, name, on[action], re[lv], title, type, all spring to mind.
They're very context-specific.

So, your idea seems wrongly-huffman coded to me, if you see what I mean.
If I was to make a guess, I would say the most often, someone would want
to set a class. Second most often, and quite a way behind, setting an
id. Some way behind that setting some other attribute.

So I would suggest a modified solution:
        
        ## Different way {different}
          
        Setting just a name should set the class. Otherwise, it might be
        that we want to set *a reference*{ref:references}
        
        {references}: title="A reference also sets the tag ID"
        {otherclass}: title="I always want to set this title on
        class='otherclass' tags"

giving:

        <h2 class="different">Different way</h2>
        
        <p>Setting just a name should set the class. Otherwise, it might
        be that we want to set <em id="references" title="A reference
        also sets the tag ID">a reference</em></p>

If you see what I mean. Trying to make it less verbose in the common
case, and differentiating between plural references (like class=) and
singular references (like id=), and encouraging people to use to markup
correctly. It also means you can pull out warnings when references get
incorrectly re-used: I know we've had the discussion about how much help
to give a user on this list before, but I still don't like the idea of
failing silently and expecting the user to memorise the references in
use in a current document.

What do you think?

--bob.

PS. If you're wondering where 'otherclass' was used; it wasn't. I was
going to apply it to the "Setting.." paragraph, but couldn't figure out
how - and also, how would you figure out that the {ref:references}
applied to the em, and not the p?



More information about the Markdown-Discuss mailing list