SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems caused by omitting tags in HTML 4

    HTML 4 allows authors to omit some tags. I'm preparing a presentation where I will discuss the advantages and disadvantages of omitting tags. However, I'm having trouble coming up with real-world problems caused by omitting tags.

    Specifically, I'd like to show a code example where omitting a tag causes a real-world problem. Can anyone help me come up with one? Thanks.

  2. #2
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Forgetting to close a <div id="header"> div and having a set height and overflow:hidden; on it.
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RyanReese View Post
    Forgetting to close a <div id="header"> div and having a set height and overflow:hidden; on it.
    Thanks for the response, but not closing a DIV will result in a validation error. I'm curious about elements that can be left unclosed within a valid document. Some examples are P, LI, DT, DD, TR, TH, TD.

  4. #4
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Internet Explorer has problems if you do not close your P-tags. Essentially, if the P-tag isn't closed, any subsequent block-level tags that would usually implicitly close the P-tag are in fact placed inside the P.

    In the following example, the TABLE will have a margin of 10px from the container, and will have a border around it:

    Code html4strict:
    <p style="margin:5px;border:1px solid #000000">...
    <table>...
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  5. #5
    SitePoint Wizard silver trophybronze trophy
    Join Date
    Jul 2008
    Location
    New York, NY
    Posts
    1,432
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There should be no technical problems – barring browser bugs – from omitting the tags that HTML allows to be omitted. The reason you're allowed to omit them is because they're syntactically unnecessary: their presence can be unambiguously implied.

    The main drawback of omitting tags is that it can make the markup harder to read for human beings.
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by C. Ankerstjerne View Post
    Internet Explorer has problems if you do not close your P-tags. Essentially, if the P-tag isn't closed, any subsequent block-level tags that would usually implicitly close the P-tag are in fact placed inside the P.
    I confirmed this bug in IE6 and IE7. It did not show up in IE8 using a test document. Thanks, this is a good example.

    Thanks to all others who responded as well. I now have a better understanding of this issue.


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
  •