with Imagination: by Dustin Diaz

./with Imagination

A JavaScript, CSS, XHTML web log focusing on usability and accessibility by Dustin Diaz

Totally Compliant Markup

Wednesday, January 25th, 2006

Inspired by a friend:

xhtml at its finest

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <title>unobtrusive css</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <style type='text/css'>
    .table { display:table; }
      .tr { display:table-row; }
        .td { display:table-cell; }
    .blue { color:blue; }
    .bold { font-weight:bold; }
    .verdana { font-family:verdana; }
    .hand { cursor:pointer; }
  </style>
</head>
<body>
  <div class='table'>
    <div class='tr'>
      <div class='td'>
        <span class='verdana bold'>My First Tableless Website!</span>
      </div>
      <div class='td'>
        <span class='verdana'>To See More Information on how to
        make your first website...</span>
      </div>
      <div class='td'>
        <span class='verdana blue hand'
        onclick="window.open('http://www.example.com');">
          click here
        </span>
      </div>
    </div>
  </div>
</body>
</html>

Any questions?

44 Responses to “Totally Compliant Markup”

  1. Natalie

    <div class=’tr> I believe you’re missing an apostrophe. :D

    I’m dying to know…. why?

  2. Michael Wales

    Haha, I was going to mention the same thing - just a typo.

    Why would you want to do this though?

  3. Lea

    Natalie, I think he’s trying to comment about how perfectly compliant validation means nothing if the tags and structure of the website are being abused, completely unsemantic, and reverting to the sins of our table-layout-loving peers. Or something. :-)

  4. Nathan Smith

    Yeah, I think the jist of it is: You gotta walk the walk, not just talk the talk. I actually saw a local company pushing a packaged product called “Web Standards,” which has nothing to do with web standards, and is completely invalid code. It’s more than a buzz-word, and just passing the W3C validator doesn’t mean we’re adhering to best practices.

  5. Raanan Avidor

    I have only one thing to say:
    LOL!!!
    Sorry…
    Had to do it.
    I think the <div class=’tr> is just a typo.
    Am I right?

  6. Jon

    yuk!

  7. Mauricio Samy Silva

    Two questions:
    1-) Why use ‘blue’, ‘verdana’, ‘bold’, ‘hand’ for classes names?.
    These are presentational names. Use class with semantics in mind.

    2-) Why ‘click here’ for the link text?
    When calling the user to action, use brief but meaningful link text

  8. Michael Odden

    I believe you need a type-attribute on the style-element. Otherwise perfectly compliant xhtml =) And this is actually a pretty good-looking example compared to how nasty “standars-compliant” markup many people actually write. :P

  9. Binny

    Works fine in Firefox - but the values ‘table’, ‘table-row’ and ‘table-cell’ are CSS 2 - so it won’t work in IE. That basically kills the idea.

    PS : I think that the missing ‘ was a typo.

  10. Jim A.

    I think you’re all reading a bit too much into this. It’s just a joke inspired by a hack that his friend was trying out.

    As noted, IE didn’t like it /insert shocked smiley here/ so he didn’t use it.

  11. Jason Beaird

    * Stylesheets embedded in the page?

    * Using css to recreate tables?

    * Using css to recreate a link?

    * Using css to recreate a <strong> tag?

    * Using css to recreate a <font> tag?

    * No type or media attributes on the style block?

    * Nested divs to recreate the exact structure and bloated code of a table?

    * Single quotes instead of double quotes for class attributes?

    * Missing closing quote on one of the tags?

    * Using js to make a span tag into a link?

    Looks good to me. You left out one thing though. Just below the body tag, you need to add the following:

    <div class='h1 bold fuscia blink>Welcome to MySpace!</div>

    Then, in the css, please add the following.

    .h1 { font-size:100px; }

    .fuschia { color: fuschia; }

    .blink { text-decoration: blink; }

    Thanks!

  12. Jason Beaird

    Not allowed to use lists in the comments, eh?

  13. Natalie

    @Lea… thanks- I got that much. I was wondering why someone would do that? It seems like a lot more work to recreate the old wheel with CSS than to just keep things simple without all that mess.

    Fun example, Dustin… more people should see how silly it looks.

  14. Elliot Swan

    Sadly, I’m pretty sure I’ve seen worse…

  15. Justin Perkins

    I’m trying to figure out where this idea came from, but I think I already know…

    I like the class=”verdana blue hand” the best, that looks like my first attempts at CSS layouts ;)

  16. Dustin Diaz

    Oh My! And I tried ever so carefully to get it right the first time. Good catch Natalie. And yes to all, it was a typo. I’ve corrected my mistake on the ‘tr’. Now my code is flawless!

  17. Dustin Diaz

    Out of order:

    @Michael: Thanks for another small catch. You’re right. I added the type=”text/css” attribute on the style element.

    @Mauricio: Read the comments. I think you’ll find that there’s several other things “not so great” about this markup.

    @Lea: Zactly.

    @Natalie: This does look funny doesn’t it. It’s a bit extreme, but I’m sure we’ve all seen close.

    @Justin: This idea just came from me and a coworker just sitting around in the hallways. We couldn’t stop laughing. It was a perfect idea. I’m glad you liked the ‘verdana blue hand’ bit. I put a lot of thought into that one.

    @Jason: Sorry. No lists. I’m getting frustrated with the way WP munches my comments. I need to do some hacking in the near future. I fixed it up in the meantime to be separate paragraphs.

    @All: None of this code was actually tested to see if it actually ‘does something’ - the point of the exercise was just to poke fun on a buzzword “tableless compliant markup”

  18. Justin Perkins

    poke fun on a buzzword “tableless compliant markup”

    Dude, that ain’t no buzzword in 2006. Even AJAX is sooooo last year.

  19. James Mitchell

    Dustin,

    That was hillarious, I too couldn’t help but laugh. Thanks!

  20. Lance Fisher

    nice!

  21. Jesse

    ha! Sarcasm can come through on the interweb ;)

  22. Hooney.net ★ 후니넷 » 유효성 통과는 최선이 아니다.

    [...] 456bereastreet에 “Validity does not equal best practices“라는 재밌는 글이 등록됐다. Dustin Diaz의 글에 대한 자신의 의견을 담은 글인데, 비슷한 고민을 했었던 나에게 많은 공감을 준다. [...]

  23. Bramus!

    Now that’s a kick in the crotch! *ouch* :D

  24. Jonathan Holst

    I think the inline JS is a bit weird… You might as well use inline CSS as well, since that is also XHTML compliant. You should rather have made an unobtrusive approach to the JS as well.

    Other than that, good job. Mind if I get inspired to my next project? ;-)

  25. Totally Compliant Markup at Lvx ex Caelis

    [...] WHAT THE HELL!! (via Dustin Diaz) [...]

  26. Ara Pehlivanian

    Hahahahahahahaha… must bookmark to use as example of what not to do.

  27. draco

    Hahahhaa, priceless. I can’t stop laughing.

  28. Dave

    OH DEAR GOD, THE NAUSTALGIA!!!

  29. Pascal Pensa // Totally Complaint Markup

    [...] Totally Complaint Markup — Best practices, anyone? Any one?! [...]

  30. Tim Hill

    just a note on this, but can you actually use .tr and .td even though they are html elements names?

    It would be bad practice anyway right because it could confused with tr, td.

    I’m not having a go at the code cause I can see it was a joke just curious.

    Thanks,

  31. [RB]

    Not a big fan of using class attribute myself, prefer to use inheritance in CSS and only use class if absolutely necessary. Also I’m very confused why you’d use class names like “table”, “tr”, “td”, “verdana” etc? OR is it meant to be a sarcastic joke?

  32. [RB]

    LOL oh ok, I didnt notice the ‘Humor’ tag at the top
    :$

  33. medyk

    I think site would validate much better as XHTML 1.1 ;-)

  34. aJ

    lol.. This is so funny :)

  35. BarelyBlogging » Blog Archive » links for 2006-03-23

    [...] Totally Compliant Markup (Funny) (tags: css html funny) [...]

  36. ShortStuff » Blog Archive » Semantics? Bah!

    [...] There have been some nice examples lately about how not to mark up documents. Even though they’re totally valid, it’s against all good semantic design practices to use CSS in such a way. [...]

  37. TrevC

    Too bad the good ‘ol marquee and blink tags would break it;) Some giant animated gifs would help too.

  38. Pig Pen - Web Standards Compliant Web Design Blog » Blog Archive » Totally Compliant Markup

    [...] Totally Compliant Markup that isn’t that hot is actually quite common - but are we suggesting non-compliant markup is the highway to best practice? No. Just that validation is only the starting point and not the end. (via Roger) [...]

  39. Max Design - standards based web design, development and training » Blog Archive » Some links for light reading (21/3/06)

    [...] Totally Compliant Markup [...]

  40. Me, Myself And I » Pech gehabt

    [...] Zum Abschluss noch ein Link zum Schmunzeln (für die, die's verstehen ) Published in: [...]

  41. Marianito

    You are totally right!!!
    Indeed, a valid code itself does not mean automaticaly a semantic and structural code as well.
    Marianito :(

  42. Hooney.net » 유효성 통과는 최선이 아니다.

    [...] 456bereastreet에 “Validity does not equal best practices“라는 재밌는 글이 등록됐다. Dustin Diaz의 글에 대한 자신의 의견을 담은 글인데, 비슷한 고민을 했었던 나에게 많은 공감을 준다. [...]

  43. Semantic Web

    The idea was that validated code isn’t how we’d really do it, and most would prefer the easier route of just putting in “clumsy” code like google rather then inserting spans and all that nonsense.

  44. misha

    heh, lol :D
    What I don’t get is why so many people wrote so serious comments :) are they kids? robots?…

Get "JavaScript Design Patterns"

"As a web developer, you'll already know that JavaScript™ is a powerful language, allowing you to add an impressive array of dynamic functionality to otherwise static web sites. But there is more power waiting to be unlocked--JavaScript is capable of full object-oriented capabilities, and by applying OOP principles, best practices, and design patterns to your code, you can make it more powerful, more efficient, and easier to work with alone or as part of a team."

Buy JS Design Patterns from Amazon.com Buy JS Design Patterns from Apress

All content copyright © 2003 - 2009 under the Creative Commons License.

Archives | Blog Search