

Death To The Div - kingkool68
http://www.russellheimlich.com/blog/death-to-the-div/

======
byoung2
You can achieve the same effect now using XHTML namespaces. I defined
<question:required>, <question:optional>, <question:subquestion>,
<answer:trigger> tags when working on a dynamic survey application I did that
would hide or display followup questions based on answers to previous
questions.

~~~
bbx
I'm quite interested in how you use it. Do you have an example?

~~~
smanek
Same way you use namespaces in any other XML document. Do something like:

    
    
       <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:question="http://www.my.unique/ns/question">
       ...
    

I love being able to use pure SVG markup in XHMTML just by having it in a
separate namespace (of course, there is trouble in IE land ...)

~~~
byoung2
Exactly like smanek described to define the tags. Then you use them like this:

    
    
      <question:required>
        <question:text>
          Would you recommend us to a friend?
        </question:text>
        <answer:choice>
          <input type="radio" value="Yes">
        </answer:choice>
        <answer:trigger>
          <input type="radio" value="No">
        </answer:trigger>
        <question:subquestion question:trigger="No">
          Please explain why you wouldn't recommend us:
            ...
        </question:subquestion>
      </question:required>
    

I then used jQuery to bind events to the newly created tags to hide/display
subquestions based on the response, and css to style it.

------
fretlessjazz
Yes! I've always thought that HTML should be more like XML in that arbitrary
tags should possess little presentational meaning without an associated
stylesheet. Perhaps we'll call this new concoction... HXTML!

~~~
sho
I can't tell if you're being sarcastic or not, but let's remember that <div
id="article"> is just as meaningless as <article> without the stylesheet, and
the second one looks nicer, and has more chance of becoming an (unofficial?)
standard.

~~~
lsc
The difference is that a non-expert (such as myself) probably has a rough idea
what div means. To know article is actually a div, I'd have to make sure there
wasn't a valid html <article> tag.

~~~
schammy
That's a good point. I learned all my web development skills by looking at
other people's code. If they were using tags that weren't actually "real" HTML
tags, but just ones they made up and defined with CSS, it would have been a
hell of a lot harder to get to where I am today.

~~~
mistermann
Ah yes, very good point!

------
DanielStraight
I like this thought, but I'm not going to suggest that I can see all the
ramifications and which ones we'd all end up hating in 10 years.

~~~
CamperBob
Like never being able to define another HTML keyword again without hosing
random sites that used it first?

~~~
gregc
Would the DOCTYPE declaration of the html version be able to overcome that
problem?

~~~
kingkool68
YES!

------
totalrager
I'm probably wrong, but isn't this exactly what XSLT does? You define your
custom tags and document structure in xml and then apply the visual styles
with xsl?

~~~
nimbix
This would be a lossy transformation. An <address> tag would still need to be
transformed into a <div> which would destroy the association between the tag
name and its contents. After that getElementsByTagName('address') wouldn't
return any results, browser plugins wouldn't see the connection between the
original and rendered data, etc.

~~~
hellotoby
I hate to nitpick. But <address> is probably a bad example in this case as the
tag <address> already exists in HTML 4.

------
ars
I agree 100%.

This would make it a lot easier to edit pages with tricky navigation divs. It
would help in many other places too.

I always thought that was (on of) the _point_ of css, with display essentially
defining what a tag was.

------
hellotoby
You can also achieve the same effect using XML and XSLT.

[edit]^ beaten by the few minutes it took me to log in! Great minds et al.

~~~
aw3c2
Sadly there is an important feature missing in one of the bigger browsers:
Firefox does not support disable-output-encoding.

<https://bugzilla.mozilla.org/show_bug.cgi?id=98168>

The bug was opened almost exactly 8 years ago. All other major browsers
support XSLT quite nicely.

------
mahmud
Lispers had this for ages too; CL-WHO lets me define my own tags and define
what to translate them to, divs or spans or whatever.

------
mcav
One problem with allowing arbitrary elements is that the browser won't know
whether element <foobar> should display as block, inline, etc. CSS styles
would need to be specified accordingly whenever custom elements would be used.

~~~
chime
Treat it exactly like a div. So display as block with default div positioning,
margin, border etc. CSS can then customize as needed.

~~~
d4rt
This has the side effect of being unable to introduce any new tags in the HTML
spec which have any properties different to div. (How would the browser know
if it was a pseudodiv or a new tag? Possibly DOCTYPE, but that as a switch has
had a varied history, which is one of the reasons for HTML5's <!DOCTYPE
html>.) This solution creates more problems than it solves.

------
hellotoby
Also interesting to note is that FF3 (and quite possibly older versions)
interpret and display custom tags which have been styled using CSS.

------
pedalpete
i've been thinking about this considerably lately. Isn't this in many ways
what facebook has done with FBML? Just created there own tags, and get a
javascript to manipulate it?

I understand that it is a dtd, but can't you create any element you want and
define it's behaviour in a dtd? I'm still just getting into the research on
this.

------
schammy
Meh, I don't see the problem with "div soup". The only thing I agree with
that's mentioned in the article is that at least you could tell where a
specific tag started and ended. But whenever I nest div's more than a few
levels deep, I always leave comments in my code for the closing tags to state
what specific id/class they are closing. Is that really so hard? No, it's not.

Also, as others have mentioned, having made-up tags littered throughout a
site's HTML would lead to two problems:

\- For people learning HTML, you'd have no idea what tags are real and which
are make-believe

\- It would be hard to update the HTML standard in the future without breaking
a bunch of sites

Both of those are serious problems from my POV.

~~~
AlisdairO
It's a big problem for accessibility. Modern web pages are a nightmare for
screen readers, for example. Tags which explicitly mark where the navigation
is, amongst other things, would be a great help.

I'm not sure that I see the value of just being able to define whatever tags
you want, though. Sounds like a recipe for disaster to me.

