none
Warning: In XHTML 1.1 the tag <ul> cannot contain the tag <p> RRS feed

  • Question

  • The following html:
    <ul>
     <li> <b> Title 123456 </b> </li>
     <p style="margin:0"> Text 123456. </p>
    </ul>

    generates the warning:
          In XHTML 1.1 the tag <ul> cannot contain the tag <p>

    My questions are as follows:

    1) What I am trying to do is display 2 lines of text.  The first line is a 'title' and contains a bullet along with the title text.  The second line is descriptive text that provides more details about the title.  What is the correct html to use that eliminates this warning message?

    2) Where can I find the HTML specifications that describe this problem and how to correct it?

    Thank you,

     

    Ian

     

    • Edited by IB00 Wednesday, May 19, 2010 9:25 PM correction
    Wednesday, May 19, 2010 9:23 PM

Answers

  • I'm curious:  Is there a reason you are using XHTML 1.1?

     

    But in any event, put the paragraph inside the list element.

    • Marked as answer by IB00 Wednesday, May 19, 2010 10:19 PM
    Wednesday, May 19, 2010 9:32 PM
  • The way to do this is to use a <br/> to give the new line in the list item, rather than a paragraph tag, so use Shift-Return to do this.

    As for a specification for HTML use http://www.w3.org/TR/html4/

    You can also find a good reference at http://reference.sitepoint.com/html

    HTH

    Ian
    MS MVP Expression

    http://www.ew-resource.co.uk
    http://www.fp-resource.co.uk


    Ian Haynes
    • Marked as answer by IB00 Wednesday, May 19, 2010 10:20 PM
    Wednesday, May 19, 2010 9:33 PM
  • Think about what you are doing. You are creating a list but putting things in the list not in list elements.

    <ul>
     <li> <b> Title 123456 </b> </li>
     <li> Text 123456. </li>
    </ul>

    Would be appropriate as would

    <ul>
     <li> <strong> Title 123456 </strong> <br />
     Text 123456. </li>
    </ul>

    Alternatively it sounds like what you want maybe a definition list.

    <dl>
       <dt>Title 123456</dt>
       <dd>Text 123456</dd>
    </dl>

    With a style definiton of:

    dt {font-weight: bold;}
    dd {margin-left: 0;}

    Like the others I wouldn't recommend using XHTML 1.1 at all. It should really only be used for web applications. Use the default

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    MS MVP Expression Tutorials & Help http://by-expression.com
    • Marked as answer by IB00 Wednesday, May 19, 2010 10:20 PM
    Wednesday, May 19, 2010 9:52 PM

All replies

  • I'm curious:  Is there a reason you are using XHTML 1.1?

     

    But in any event, put the paragraph inside the list element.

    • Marked as answer by IB00 Wednesday, May 19, 2010 10:19 PM
    Wednesday, May 19, 2010 9:32 PM
  • The way to do this is to use a <br/> to give the new line in the list item, rather than a paragraph tag, so use Shift-Return to do this.

    As for a specification for HTML use http://www.w3.org/TR/html4/

    You can also find a good reference at http://reference.sitepoint.com/html

    HTH

    Ian
    MS MVP Expression

    http://www.ew-resource.co.uk
    http://www.fp-resource.co.uk


    Ian Haynes
    • Marked as answer by IB00 Wednesday, May 19, 2010 10:20 PM
    Wednesday, May 19, 2010 9:33 PM
  • Think about what you are doing. You are creating a list but putting things in the list not in list elements.

    <ul>
     <li> <b> Title 123456 </b> </li>
     <li> Text 123456. </li>
    </ul>

    Would be appropriate as would

    <ul>
     <li> <strong> Title 123456 </strong> <br />
     Text 123456. </li>
    </ul>

    Alternatively it sounds like what you want maybe a definition list.

    <dl>
       <dt>Title 123456</dt>
       <dd>Text 123456</dd>
    </dl>

    With a style definiton of:

    dt {font-weight: bold;}
    dd {margin-left: 0;}

    Like the others I wouldn't recommend using XHTML 1.1 at all. It should really only be used for web applications. Use the default

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    MS MVP Expression Tutorials & Help http://by-expression.com
    • Marked as answer by IB00 Wednesday, May 19, 2010 10:20 PM
    Wednesday, May 19, 2010 9:52 PM
  • I'm using Expression Web/VS2008 and, up until my posting, was using ' XHTML 1.0 Transitional'.   I made the switch simply for testing purposes.

    I have limited HTML experience and didn't realize the <p> tag could be placed inside the list item.  

    Thanks,

    Ian

     

    Wednesday, May 19, 2010 10:19 PM
  • Thanks for the references.   I've already tried wading through the http://www.w3.org/TR/html4/ documentation in an effort to understand why the warning was being generated.   I found the warning to be rather vague - there appear to be less than a handful of other postings on the topic and I couldn't use it to trace the problem in the html specifications.  This quite likely reflects my lack of html experience.

    Thanks,

    Ian

    Wednesday, May 19, 2010 10:31 PM
  • "This quite likely reflects my lack of html experience."

    It does. :)  That error is not specific to XMTL 1.1.  It's a matter of proper ul and li syntax.

    Wednesday, May 19, 2010 11:03 PM