Results 1 to 9 of 9

Thread: CSS validator question with ul and span

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default CSS validator question with ul and span

    ok, I'll bite. What is wrong with the following. I'm having a bit of trouble figuring it out.

    Code:
    <span style="color:tan;"><ul><li>decrease pain 
    <li>decrease disability 
    <li>improve strength of contractions
    <li>increase the size and symmetry of the muscles 
    <li>return to a tonic type contraction 
    <li>facilitate the anticipatory function 
    <li>decrease the rate of LBP recurrence</ul></span>

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there james438,

    You are attempting, incorrectly, to place a block-level element ul within an inline element span.

    One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").
    coothead

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    I guess that does help out a little, but if that is so why does the following not work?
    Code:
    <ul><span style="color:tan;"><li>decrease pain 
    <li>decrease disability 
    <li>improve strength of contractions
    <li>increase the size and symmetry of the muscles 
    <li>return to a tonic type contraction 
    <li>facilitate the anticipatory function 
    <li>decrease the rate of LBP recurrence</span></ul>
    Here is the link to the validator page where it shows the errors I am talking about.

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by james438 View Post
    ok, I'll bite. What is wrong with the following. I'm having a bit of trouble figuring it out.

    Code:
    <span style="color:tan;"><ul><li>decrease pain 
    <li>decrease disability 
    <li>improve strength of contractions
    <li>increase the size and symmetry of the muscles 
    <li>return to a tonic type contraction 
    <li>facilitate the anticipatory function 
    <li>decrease the rate of LBP recurrence</ul></span>
    Quote Originally Posted by james438 View Post
    I guess that does help out a little, but if that is so why does the following not work?
    Code:
    <ul><span style="color:tan;"><li>decrease pain 
    <li>decrease disability 
    <li>improve strength of contractions
    <li>increase the size and symmetry of the muscles 
    <li>return to a tonic type contraction 
    <li>facilitate the anticipatory function 
    <li>decrease the rate of LBP recurrence</span></ul>
    Here is the link to the validator page where it shows the errors I am talking about.
    both of those are incorrect... this second one is a little better but still not correct. if all you want to accomplish is to make the color of the li text tan... then you cause just use a css style sheet.. if you have an external style shee that you link to you can just add the properties to it, however I am going to assume that you do not have that, and as such we will use an embedded style sheet that you put at the top of the page. like so
    Code:
    <DOCTYPE....>
    <html>
    <head>
       <title>TITLE OF PAGE</title>
    <style type="text/css">
    <!--
    ul li {
       color: #d2b48c;
    }
    -->
    </style>
    </head>
    Its always better to use the hexidecimal equivalent on your colors. for other colors see http://halflife.ukrpack.net/csfiles/help/colors.shtml
    then you also need to modify the content of the list itself, and close the ending list items.
    Code:
    <ul>
        <li>decrease pain</li>
        <li>decrease disability </li>
        <li>improve strength of contractions</li>
        <li>increase the size and symmetry of the muscles </li>
        <li>return to a tonic type contraction</li>
        <li>facilitate the anticipatory function </li>
        <li>decrease the rate of LBP recurrence</li>
    </ul>
    also note that i took out the <span> tags. now your list is valid markup

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

    Default

    It's valid HTML anyway: the </li> is implied. I find the explicit form neater, though.
    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!

  6. #6
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Thanks, I didn't think to style the ul or li tags.

  7. #7
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    I generally leave out the </li> because they do not need to be added to validate the page (sort of like <hr></hr>), so for me I like to leave out the extra code.

  8. #8
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by james438 View Post
    I generally leave out the </li> because they do not need to be added to validate the page (sort of like <hr></hr>), so for me I like to leave out the extra code.
    <hr> is just <hr>
    there is not closing horizontal rule for that.. its like the <input> tag or <br> break rule tag

    if you wanted to do an ending tag on that you would need to do so by
    <hr /> -- <input /> -- <br />

    etcetc
    but those are only required in xhtml, which IE still fails to recognize

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

    Default

    Correction: they're only valid in XHTML. In the HTML DOCTYPE they're defined as singleton tags, which means that they have no ending tags; </hr> is invalid. <li>, on the other hand, is like <p>: it does have and require a closing tag, but it's implied when the parser encounters another <li> or the parent element closes.
    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!

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
  •