SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Validate the <ul> code

    hi all

    i m not understanding the error coming at w3 validator for my code .

    how can i validate this

    HTML Code:
    <!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=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <ul>
    The bots track the following and store in a database:
    <li>Auto approve comment links</li>
    </ul>
    </body>
    </html>
    this is the error
    Code:
    Line 10, Column 1: character data is not allowed here
    
    The bots track the following and store in a database:
    
    You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include:
        putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>), or
        forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or
        using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,888
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    You can't have 'loose' text inside a <ul> ... the only things you can have in there are <li>s.

    If you don't want that first line of text to be bulleted, you'll need to put it in a <p>...</p> before the opening <ul> tag.

  3. #3
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Stevies got it right, and it may also be possible that text should be a numbered heading, not a paragraph, but that depends on the context on the page.

    Bottom line though is the only thing that can come as children of OL or UL is LI -- loose text or other tags are not allowed/invalid/don't make any sense in the first place. You might have the heading for a list, that doesn't make it part OF the list.

  4. #4
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks stevie for the clarification

    vineet

    Quote Originally Posted by Stevie D View Post
    You can't have 'loose' text inside a <ul> ... the only things you can have in there are <li>s.

    If you don't want that first line of text to be bulleted, you'll need to put it in a <p>...</p> before the opening <ul> tag.

  5. #5
    SitePoint Wizard bronze trophy Black Max's Avatar
    Join Date
    Apr 2007
    Posts
    4,029
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    You might consider a definition list.


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
  •