Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: SSI errors on W3C validator

  1. #1
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default SSI errors on W3C validator

    I'm new to this SSI but basically I've done really simple tries by the book, as it were, and they come out looking right. But when I test them here:

    http://validator.w3.org/

    There are errors related to the fact that the "DOCTYPE" from the original (or included) html is showing up in the "script".


    Example of what this script looks like before (when I wrote it):

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <!--#include virtual="/ssi-test/css-in.html" -->
    </body>
    </html>



    And when processed and read through the web:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>


    <style type="text/css">

    .bigfont {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 36px;
    font-style: normal;
    font-weight: bold;
    text-decoration: line-through;
    }

    table {background: #9999CC
    }
    body {
    background-color: #FFFF33;
    }
    </style>


    </head>

    <body>

    <p class="bigfont">I WENT RUNNIN THROUGH THE FOREST</p>
    <p>I WENT RUNNIN THROUGH THE FOREST</p>


    <table width="717" height="251" border="0" cellpadding="0" cellspacing="5">
    <tr>

    <td>&nbsp;</td>
    </tr>
    </table>

    </body>
    </html>


    </body>
    </html>





    Error 1 example:

    Line 9, Column 2: "DOCTYPE" declaration not allowed in instance .

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or




    Error 2 example:
    Line 10, Column 42: document type does not allow element "html" here .

    <html xmlns="http://www.w3.org/1999/xhtml">



    The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

    One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).



    Sorry this is so long.
    Does anyone know what this is about?

    Thanks much!
    Last edited by questions; 01-25-2008 at 06:33 AM.

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Your include page already has full headers and everything

    Code:
    <!--#include virtual="/ssi-test/css-in.html" -->
    This page.

    So you either need to a) remove ALL headers, titles, html and body tags OR b) don't put them on the page with the include. (i.e. just a blank page with only the include statement in it.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default

    Really? I thought all pages have to have the DOCtype and head and body tags on them. You are saying I can leave some out? On either page? Would it still work? I will give it a try.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    All pages should have those things, but unless your includes are stand-alone pages, they do not need them as long as the pages that they are going to be included on have them. Remember, it is the served code as a whole that should validate as a page, not the resources that contribute to it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default

    You guys rock! I finally got it... I really looked everywhere for an answer to this but I think it seems so obvious to everyone that no one discusses it.

    So, what I've done is leave all the head and body and html tags in the .shtml file and in the include file took that out... because I might want to include 2 or more files and so none of them should have that information in them.

    I was confused a while with where to put the CSS info, but that also needs to go into the .shtml file that has all the includes stuck into it because it's "header" info.

    Thanks a lot!!!!!!!!!!! I am new to all of this (well, the correct and simple way of doing things...)

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You probably want this DOCTYPE:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    Transitional DOCTYPEs are outdated, and XHTML isn't properly supported yet.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default

    Huh. I read on someones tutorial page to put XHTML Strict down. The DOCTYPE I got is from Dreamweaver CS3... you'd think that would be up to date. So I just left it as the Dreamweaver.

    What do you mean by outdated?

    I thought the order goes from HTML to XHTML.

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What do you mean by outdated?
    The "transitional" period from HTML3 to HTML4, for which that DOCTYPE (well, actually the HTML version; the XHTML is a direct translation of that to XML) was designed, was about ten years ago. Now, designers use it just to excuse sloppy code.
    I read on someones tutorial page to put XHTML Strict down.
    Then whoever wrote that tutorial was a) wrong, b) intentionally misleading, or c) misunderstood by you (mm, dodgy use of passive voice). XHTML is newer than HTML by about one month. It's a parallel standard, and does not obsolete HTML. More importantly for our purposes, IE is currently completely unable to render it. See: http://www.webdevout.net/articles/beware-of-xhtml
    The DOCTYPE I got is from Dreamweaver CS3... you'd think that would be up to date.
    Considering the abysmal quality of code that Dreamweaver spouts, I would expect nothing of the sort.
    Last edited by Twey; 01-28-2008 at 07:34 AM. Reason: Factual error: closer to ten years.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default

    Thanks. Learning so much...

  10. #10
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default

    It seems that for my basic purposes of putting together a simple web page, there is no difference between XHTML & HTML, as the tags, attributes, etc. are the same. It's just the declaration of DOCTYPE that I need to change.

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
  •