SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    SitePoint Guru tictike's Avatar
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    863
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I have no idea how this could possibly happen..

    I have a page with 6 data tables on it. The problem is one table has about half its row with different widths, but all 6 tables reference the same css file and the page does validate 4.01 strict. how in the world can some of my rows just decide to be about 100px shorter than the other 400 or so rows on the page?

  2. #2
    SitePoint Wizard bronze trophy Black Max's Avatar
    Join Date
    Apr 2007
    Posts
    4,029
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Interesting. Got a link?

  3. #3
    SitePoint Guru tictike's Avatar
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    863
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was in the middle of posting a link when I noticed the second cell in some rows had two opening tags surrounding the data. But still, shouldn't the validator have caught this?

  4. #4
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    The end tags for TR and TD are optional.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  5. #5
    SitePoint Guru tictike's Avatar
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    863
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Even with a 4.01 strict dtd?

  6. #6
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In HTML they are optional. In XHTML they are not optional.

    This is one of the reasons that I'm considering using XHTML 1.0 Strict as my default instead of HTML 4.01 Strict. One reason that I'm hesitant to switch is that most people are unaware that XHTML documents must be valid.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  7. #7
    SitePoint Wizard bronze trophy Black Max's Avatar
    Join Date
    Apr 2007
    Posts
    4,029
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Kravvitz, only somewhat off topic: what's your thoughts on XHTML 1.0 Transitional as a default doctype? I'm curious as I'm involved in a big redesign of the ugly, ugly site in my sig, and since I'm not the lead designer (thankfully for all involved), I'm looking over his virtual shoulder pretty much every step of the way. I don't know whether he intends to go Strict or Transitional, but I'm curious as to any possible downside of Transitional.

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz View Post
    This is one of the reasons that I'm considering using XHTML 1.0 Strict as my default instead of HTML 4.01 Strict.
    Unless you serve that XHTML as an application of XML there won't be any difference. If you serve it as text/html – which you'll have to do if you want accessibility for IE users – you can still omit those tags because you're still using HTML.

    Quote Originally Posted by Kravvitz View Post
    One reason that I'm hesitant to switch is that most people are unaware that XHTML documents must be valid.
    An XML document doesn't have to be valid, as such, but it must be well-formed. Again, this won't make a difference if served as text/html.
    Birnam wood is come to Dunsinane

  9. #9
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tictike View Post
    Even with a 4.01 strict dtd?
    Yes. HTML is SGML, and is therefore very versatile. I don't recall the exact interpretation rules, but basically, a tag is automatically closed when an opening tag at the same or higher lever (or a closing tag at a higher level) is encountered.

    In the example below, the P is automatically closed by the UL (since a UL can't be contained in a P), and each LI is automatically closed by the next LI (since an LI can't contain another LI). The LI is not closed by the nested UL, though, since an LI can contain a UL.
    Code html4strict:
    <p>This is a paragraph in a fully-valid HTML 4.01 excerpt.
    <p>Note that lower-level tags will <strong>not</strong> close a tag automatically
    <ul>
      <li>Because UL and P are at the same level, a P is automatically closed by a UL.
      <li>LIs are also closed by other LIs
        <ul>
          <li>LIs are not closed by new ULs, though. Only by LIs or closing ULs.
        </ul>
      <li>ULs can't be closed automatically. Probably since it would create a lot of problems with nested lists.
    </ul>
    <p>Personally, I prefer to close all my tags (except for the stand-alone ones), but that's just a matter of taste (and strictly speaking verbose)
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  10. #10
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by C. Ankerstjerne View Post
    I don't recall the exact interpretation rules, but basically, a tag is automatically closed when an opening tag at the same or higher lever (or a closing tag at a higher level) is encountered.
    It's the DTD that says which tags may be omitted. There are no 'levels' as such. Inline elements don't have optional end tags because they can nest, so the presence of the end tag cannot be implied in the generic case.

    The </p> tag can be omitted without any risk for ambiguity, since a paragraph cannot contain block-level elements. Anything after the paragraph, which must be a block-level element, will therefore imply that the paragraph has come to an end.

    It's the same thing with table rows and cells. A cell can't contain another cell, so a start tag for a new cell or row implies the </td> tag. Rows can't contain anything but cells, so a <tr> tag implies a preceding </tr> tag.

    The </table> end tag, on the other hand, may not be omitted. This may appear a bit odd at first, because surely a table cannot contain anything but internal table objects?

    The reason is that the </td>, </th>, </tr> and </tbody> tags are optional. Therefore the end of the table must always be explicit. Consider the following scenario,
    Code HTML4Strict:
    <table>
      <tr><td>Cell data
     
    <p>A paragraph intended to appear after the table.
    Here, the paragraph will be considered part of the cell, since cells may contain paragraphs.

    Since there are usually a lot more TD, TH and TR elements than TABLE elements, I suppose it was an easy decision to make the </table> tag required instead of requiring end tags for the internal elements.

    A valid HTML document can always be parsed unambiguously, even if every optional tag is omitted. It may be a lot harder to read for a human, but that's another issue.
    Birnam wood is come to Dunsinane

  11. #11
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the explanation, Tommy

    The TABLE and UL requirement is also relevant for nested tables and lists, since it would be impossible to determine which level the sub-tabs were in, i.e.
    Code html4strict:
    <table>
      <tr>
        <td>
          <table>
            <tr>
              <td>
              <td>
          <!-- missing table end tag -->
        <td>
      <tr>
        <td>
        <td>
    <!-- missing table end tag -->
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  12. #12
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Black Max View Post
    Kravvitz, only somewhat off topic: what's your thoughts on XHTML 1.0 Transitional as a default doctype? I'm curious as I'm involved in a big redesign of the ugly, ugly site in my sig, and since I'm not the lead designer (thankfully for all involved), I'm looking over his virtual shoulder pretty much every step of the way. I don't know whether he intends to go Strict or Transitional, but I'm curious as to any possible downside of Transitional.
    It's best to use a Strict doctype unless you have to use an element or attribute that it doesn't allow.

    No more Transitional DOCTYPEs, please
    It's Time To Kill Off Transitional DOCTYPES
    Transitional vs. Strict Markup
    Quote Originally Posted by AutisticCuckoo View Post
    Quote Originally Posted by Kravvitz View Post
    This is one of the reasons that I'm considering using XHTML 1.0 Strict as my default instead of HTML 4.01 Strict.
    Unless you serve that XHTML as an application of XML there won't be any difference. If you serve it as text/html which you'll have to do if you want accessibility for IE users you can still omit those tags because you're still using HTML.
    I hadn't forgotten. What I didn't mention is that it is because of how the validators treat HTML 4.01 and XHTML 1.x. Since I want to always include optional end tags, it's helpful for the validator to tell me when I forget one.

    Quote Originally Posted by AutisticCuckoo View Post
    Quote Originally Posted by Kravvitz View Post
    One reason that I'm hesitant to switch is that most people are unaware that XHTML documents must be valid.
    An XML document doesn't have to be valid, as such, but it must be well-formed. Again, this won't make a difference if served as text/html.
    So valid includes being well-formed and using correct nesting? Are there any other differences?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  13. #13
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz View Post
    o valid includes being well-formed and using correct nesting? Are there any other differences?
    Well-formed in XML terms means that there's an end tag (or null end tag) for each start tag and that those appear in the proper nesting order.

    It also means that character entity references must be recognised, so there mustn't be any unescaped ampersands, e.g., in URIs. You shouldn't even use HTML4 entities like &nbsp;, since they are defined in the DTD, which a non-validating XML parser isn't required to read.

    Furthermore, there can't be any illegal characters (like malformed UTF-8 sequences) in the content.

    A conforming XML parser must not continue processing if it encounters an error of any of the aforementioned types.

    Valid XML means that the elements and attributes used conform to the specified DTD, XML Schema, etc. Using your own <foo/> element or a target="_blank" attribute with an XHTML 1.0 Strict doctype declaration makes the document invalid.

    XML parsers used by browsers are usually non-validating, which means they don't care if the document is valid or not. They just require it to be well-formed, so that they can create a DOM tree out of it. Then it's up to the rendering engine to do something useful with it.
    Birnam wood is come to Dunsinane

  14. #14
    SitePoint Guru tictike's Avatar
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    863
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So.... the code that caused my problem was:
    <td>some text</td>
    <td>some text<td> <-- missing end tag
    <td>some text</td>
    <td>some text</td>


    ..and this file validated. Did it validate because I used 4.01 Strict and not an xhtml dtd, so the browser saw this as a table cell with nothing in it?

  15. #15
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    It validated because it's valid HTML 4.01 Strict, yes. If it was XHTML, it wouldn't have validated, but this would not have solved the problem for you. If you use XHTML served as text/html, then it's still 'just' HTML, and the browser would have read it as SGML. If you use XHTML served as application/xml, the browser would either try to download the file (if Internet Explorer) or display an error message.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  16. #16
    SitePoint Guru tictike's Avatar
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    863
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you refer to text/html and application/xml, do you mean the value of the content attribute in the meta tag?

    So if I have a xhtml strict dtd but serve it as text/html what kind of document is it?

  17. #17
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tictike View Post
    When you refer to text/html and application/xml, do you mean the value of the content attribute in the meta tag?
    No, the content type cannot be specified in a meta tag, since the user agent needs to know the content type before it starts parsing the document.

    It is specified using the real Content-Type HTTP header, sent by the web server. If you wish to serve an XHTML document as real XHTML, you need to instruct the server to send the right MIME type (application/xhtml+xml). You can also use a server-side scripting language like PHP or ASP to send the header.

    Quote Originally Posted by tictike View Post
    So if I have a xhtml strict dtd but serve it as text/html what kind of document is it?
    HTML (invalid and with syntax errors). Anything served as text/html must be parsed and interpreted as HTML, even if it's XHTML, a Word document or a GIF image.
    Birnam wood is come to Dunsinane

  18. #18
    SitePoint Guru tictike's Avatar
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    863
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm. I don't think I understand. Know any good articles or links I could reference? I thought my job was to pick the right doctype and let the browser do the rest....

    tictike has a lot to learn

  19. #19
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you read the XHTML vs HTML FAQ in this forum? It explains the differences between XHTML and HTML quite thoroughly.

    The main mechanism for telling what's what on the web is the Content-Type HTTP header. It's normally sent by the web server when you request a resource from a site, and it tells the recipient what sort of data that will follow.

    If the Content-Type HTTP header says the MIME type is text/html, then the browser (or whatever application is requesting the document) must assume that it is HTML and parse and interpret it as such.

    If the Content-Type HTTP header says the document is an application of XML, then the user agent should use an XML parser. This XML parser will then examine the xmlns attribute of the root element. If that is http://www.w3.org/1999/xhtml, then the document is XHTML.

    The doctype declaration has nothing to do with it. It's only meant to be used by validators to verify that the markup is valid. Nowadays browsers also peek at it to determine the rendering mode, but that's an aside.

    The important thing to remember is that the doctype declaration has no impact on whether the document is treaded like HTML or XHTML.
    Birnam wood is come to Dunsinane

  20. #20
    SitePoint Addict
    Join Date
    May 2008
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    put the whole file into DW cs3, it gonna tell you where is problem is, thats the way what i do


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
  •