SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot irvin's Avatar
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HTML validation WEIRD errors

    Hi evryone,

    I tried to validate my html page using W3C HTML 4.01 validator, but I got the following errors:

    Line 7, column 6: end tag for element "HEAD" which is not open (explain...).
    </head>
    ^
    Line 8, column 5: document type does not allow element "BODY" here (explain...).
    <body>
    ^
    Line 12, column 31: there is no attribute "BACKGROUND" (explain...).
    <td width="34%" background="images/HeaderBg.jpg">&nbsp;</td>

    Could somebody help me to get the code right please.
    Thanks in advance.
    Cheers
    Irvin

    And here's my html code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>My page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="66%"><img src="images/Header.jpg" alt="my page" width="665" height="90" /></td>
    <td width="34%" background="images/HeaderBg.jpg">&nbsp;</td>
    </tr>
    </table>
    <div class="menuBar"> <a class="menuButton" href="index.htm">Home</a> <a class="menuButton" hrefWeb Specialist Australia="aboutus.htm" >About
    us</a> <a href="services.htm" name="link2" class="menuButton" id="link1" onMouseOver="MM_showMenu(window.mm_menu_0317153942_0,0,22,null,'link2')" onMouseOut="MM_startTimeout();" >Services</a>
    <a class="menuButton" href="portfolio.htm" >Portfolio</a> <a class="menuButton" href="testimonials.htm" >Testimonials</a>
    <a class="menuButton" href="quote.htm" >Request Quote</a> <a class="menuButton" href="reseller.htm" >Reseller</a>
    <a class="menuButton" href="contact.htm" >Contact us</a> <a class="menuButton" href="articles.htm" >Articles</a>
    </div>
    <br>
    <p>&nbsp;</p>
    <div class="footer">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><a href="index.htm">Home</a> <a href="aboutus.htm" >Privacy Policy</a>
    <a href="services.htm" >Terms Of Service</a> <a href="contact.htm" >Contact
    us</a></td>
    </tr>
    <tr>
    <td>&copy; 2003 - 2004 My page</td>
    </tr>
    </table>
    </div>
    <p>&nbsp; </p>
    </body>
    </html>

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    UK
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi irvin,

    To get rid of the first 2 errors, you need to change your link to your stylesheet to read like this:

    <link href="style.css" rel="stylesheet" type="text/css">

    (Note the lack of a / at the end of the line).

    The third error you mention is caused by using the background attribute in a <td>, which I suspect is not supported in the HTML 4.01 Transitional spec (which is the Document Type you declare on the first line). Maybe worth trying to apply this background from your style sheet using <td class="classname">?

    When I tried to validate your code myself, I also got another couple of errors caused by the line:

    <a class="menuButton" hrefWeb Specialist Australia="aboutus.htm" >About
    us</a>

    I'm not too sure quite what the hrefWeb Specialist Australia bit means, or what to do about it. Do you know why this is in the code?

    Rob.

  3. #3
    SitePoint Zealot irvin's Avatar
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rob,

    Thanks very much for your correction and kind help.
    The following code
    <a class="menuButton" hrefWeb Specialist Australia="aboutus.htm" >About
    us</a>
    Should've been written as
    <a class="menuButton" href="aboutus.htm" >About
    us</a>

    No magic in it

    About that <td class="classname">,
    I already tried this method and similar various methods using css, but it didn't work out for me.

    Do you know exactly how to display a background image in a table cell, in this case in <td> using css?

    And how to use javascript properly that follows the HTML 4.01 rules?
    Here's what I used before:
    <script language="JavaScript1.2">mmLoadMenus();</script>

    But it seems like HTML4.01 validator doesn't allow 'language' to be used, i read the tutorials in w3schools.com it says 'type' should be used instead such as
    <script type="JavaScript1.2">mmLoadMenus();</script>

    Do you know which way is the correct way to use?

    Thanks again.
    Cheers,
    Irvin
    They will run and not grow weary,
    They will walk and not be faint.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    UK
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi irvin,

    I think it is possible to assign a background image to a table cell using the following code in your stylesheet:

    td.classname {
    background: url(bgimage.gif);
    }

    Aslong as your cell has the relevant class name (<td class="classname">) and you make sure the URL is pointing to the right place it should work.

    Whilst we're talking CSS, I'd also recommend styling your links in your menubar using something like:

    .menubar a:link, a:hover, a:active, a:visited {
    color: #880000;
    }

    You can then get rid of all the class="menuButton"s in the <a href> tags - should cut down on code a bit.

    With regards to the javascript reference, I'm not too sure if there's a problem with <script type="JavaScript1.2">mmLoadMenus();</script> - I just tried pasting this into the body of your example page and it validated as HTML 4.01 Transitional on the W3C site.

    Hope that helps!

    Regards,

    Rob.

  5. #5
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by roblewis100
    With regards to the javascript reference, I'm not too sure if there's a problem with <script type="JavaScript1.2">mmLoadMenus();</script> - I just tried pasting this into the body of your example page and it validated as HTML 4.01 Transitional on the W3C site.
    Actually, that's not a valid value for the "type" attribute. The "type" is supposed to be a content type, like so:
    HTML Code:
    <script type="text/javascript">mmLoadMenus();</script>


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
  •