Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,094
    Thanks
    15
    Thanked 1 Time in 1 Post

    no <link> tag in HTML 4 - does not validate

    Code:
    <link rel="shortcut icon" href="/favicon.ico"></link>
    Error: document type does not allow element "LINK" here

    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).


    I tried to validate my HTML in the w3 validator just to see how much i needed to change and it gave this error. Does this mean that I can't use a <link> tag in HTML 4?

    Picco

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Show us your code so we can see where you've placed the link element.

  • #3
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,094
    Thanks
    15
    Thanked 1 Time in 1 Post
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>AyrshireMinis.com - a Mini E-Community</TITLE>
    <script language="JavaScript" type="text/javascript" src="/mini/js/general.js"></script>
    <link rel="stylesheet" type="text/css" href="/mini/inc/style.css" />
    <link rel="shortcut icon" href="/favicon.ico"></link>
    </HEAD>
    <BODY>
    Merci!

  • #4
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    You can use link…you just don't have to close it:

    Code:
    <link rel="stylesheet" type="text/css" href="/mini/inc/style.css">
    <link rel="shortcut icon" href="/favicon.ico">
    Note I got rid of the trailing slash in the first link…self-closing tags aren't used in HTML, only XHTML.

  • Users who have thanked rmedek for this post:

    crmpicco (10-09-2007)

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,027
    Thanks
    2
    Thanked 315 Times in 307 Posts
    Edit: Basiclly says that same as above ^^

    In HTML there are two problems with the posted code -

    Your first <link tag is using a / to close the tag. This is not permitted in valid HTML and is actually what is causing the error you posted.

    Your second <link tag is correct HTML, except that </link> is not a valid tag.

    So, if you remove the / from the first one and the </link> from the second one, it will validate as HTML (tested.)
    Last edited by CFMaBiSmAd; 10-09-2007 at 07:00 PM. Reason: too slow on the post button
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • Users who have thanked CFMaBiSmAd for this post:

    crmpicco (10-09-2007)

  • #6
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,094
    Thanks
    15
    Thanked 1 Time in 1 Post
    excellent, many thanks to both of you!

    Picco


  •  

    Posting Permissions

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