SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Just for laughs

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Location
    Colorado
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Just for laughs

    I have a site that I built for a client who has rudimentary html knowledge that he wants to use to make updates himself. I don't like this because it messes up my nice clean valid code. He just made his first updates today and the html is appalling. I went to check to see just how bad the code was and came across something that I found hilarious. This. Validates.

    (Modified to protect the guilty and shortened for your convenience)
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <title></title>
    <table>
            <tr>
              <th ALIGN=center colspan="4">Name of Event
            <tr>
              <th ALIGN=center colspan="4">Points Standings
            <tr>
              <td>Division
              <td>
              <td>
              <td>
            <tr>
              <td ALIGN=center>Pos.
              <td ALIGN=center>#
              <td>Name
              <td ALIGN=right>Points
            <tr>
              <td ALIGN=center>1.
              <td ALIGN=center>444
              <td>Name One
              <td ALIGN=right>156
            <tr>
              <td ALIGN=center>2.
              <td ALIGN=center>118
              <td>Name Two
              <td ALIGN=right>140
            <tr>
              <td ALIGN=center>3.
              <td ALIGN=center>352
              <td>Name Three
              <td ALIGN=right>140
            <tr>
              <td ALIGN=center>4.
              <td ALIGN=center>100
              <td>Name Four
              <td ALIGN=right>108
    </table>
    No <html> tags, no <head> tags, no <body> tags, not one <tr> closed, not one <td> closed, align attribute given without quotes. Isn't it wrong to have two <th> tags in one table? I know capitalizing the ALIGN is only wrong in xhtml but it just looks so wrong to me.

    To all Americans here and abroad Happy Thanksgiving!

  2. #2
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As for as I know you don't have to limit yourself to one <th> attribute per table, only one <thead>.

    As for the rest...
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,807
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    All those missing tags are optional in the HTML spec and therefore leaving them out doesn't make the page invalid. The browser is required to work out where the missing tags go and insert them itself.

    May make future maintenance much more difficult though.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I actually find it just as funny he knows how to use a doctype

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I can see it's perfectly valid HTML 4.01 Strict. The title shouldn't be empty and the ALIGN attributes ought to be replaced by CSS, but it's actually valid. Omitting tags is perfectly legitimate, although it's considered a bad practice these days since it makes the code harder to read for humans. Those attribute values don't need to be quoted, since they only consist of Latin letters.

    Some people would actually consider that pretty efficient (or at least efficacious) markup (apart from the ALIGN attributes, of course).

    I wouldn't write markup like that, but there's nothing technically wrong with it.
    Birnam wood is come to Dunsinane

  6. #6
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The table seems to misuse the TH and TD elements -- the THs seem to be heading content that ought to be outside the table, and things that should be THs are TDs. Something like the following:
    Code:
    <h1>Name of Event</h1>
    <p>Points Standings</p>
    <table>
     <caption>Division</caption>
     <tr>
      <th>Pos.
      <th>#
      <th>Name
      <th>Points
     <tr>
      <td>1.
      <td>444
      <td>Name One
      <td>156
     <tr>
      <td>2.
      <td>118
      <td>Name Two
      <td>140
     <tr>
      <td>3.
      <td>352
      <td>Name Three
      <td>140
     <tr>
      <td>4.
      <td>100
      <td>Name Four
      <td>108
    </table>
    Simon Pieters

  7. #7
    SitePoint Wizard webcosmo's Avatar
    Join Date
    Oct 2007
    Location
    Boston, MA
    Posts
    1,480
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    lot of people think its easy to develop websites. they have no idea what it takes, until they mess up things.

  8. #8
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Location
    Colorado
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ize View Post
    I actually find it just as funny he knows how to use a doctype
    The doctype is in there because I did that part of the page. The content is kept separate and is brought in by asp. I can guarantee you he has never heard of doctype.

  9. #9
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I had the same thing happen to me. I rewrote and CSS'd a page, and when I saw it online almost all the optional tags were gone (some p's where still closed), and the careful sizing I'd made of the boxes so that the page looked good in ALL resolutions/sizes was changed (so that it "fit his browser" whatever that meant) so now nothing lines up at all and everything looks like a child did it.
    He'd had my username in his footer and I made him remove it! I don't want to be associated with that kind of coding unless I'd actually done it. It's 100% valid page though (and I learned about optional tags in the process, so all in all, maybe a good experience).


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •