Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is element ‘ul’ cannot be nested within element ‘ol’? (i am getting this error from xhtml validator) help pls

Tags:

xhtml

<ol style="padding-top:0;">
<li><a href="http://www.24hourfitness.com/membership/offers/specials.html?cm_mmc=Silverfox-_-SEM-_-Google-_-Branded?">24 Hour Fitness</a></li>

    <!-- open nested list -->
    <ul>
    <li>This website would be ideal to use as a reference. The information provided lists references and is also very detailed. You feel confident in what you read in this website as being factual and helpful.</li>
    <li>source code – body section</li>

        <!-- open nested list -->
        <ol type="a">
        <li>Don't display unfriendly errors directly to the user.</li>
        <li>Used SSL/HTTPS for login and any pages where sensitive data is entered (like credit card info).</li>
        <li>Written <a href="http://www.w3.org/TR/xhtml1/" target="_blank">XHTML</a>/HTML and CSS according to the <a href="http://www.w3.org/">W3C specifications</a> and make sure they validate. The goal here is to avoid browser quirks modes and as a bonus make it much easier to work with non-standard browsers like screen readers and mobile devices.</li>
        <li>Have some system for people to contact you with suggestions and criticism.</li>
        </ol> 
        <!-- closed nested list -->

    <li>The website’s goal is to encourage membership at 24 Hour Fitness gyms.  This is very easy to determine by both the 24 Hour Fitness banner and the “Membership” banner. The website than provides a number of membership options.
    You can locate your local gyms without any problems at all.</li>
    <li>The website is quite easy to navigate around. The main reason is because of the six drop down menus at the bottom of the 24 Hour Fitness banner.
    These drop down menus remain visible and constant for the majority of the web pages in the site.
    For instance, when you click on “Shop” you are sent to a related website so the banner and the drop down menus change.</li>
        </ul>
        <!-- closed nested list -->
</ol>
like image 289
Yves Avatar asked Oct 07 '09 16:10

Yves


People also ask

What elements can be nested in UL?

The <ul> and <ol> elements may be nested as deeply as desired. Moreover, the nested lists may alternate between <ol> and <ul> without restriction.

Can we have UL inside Li?

List item elements, <li></li> , are block elements, and as such may contain other blocks, including UL and OL.

Can you have a UL in a UL HTML?

Well tough luck, but it isn't legal html to do that. Period. I used to make the same mistake all the time and it took me a long time to learn how to do it right, but eventually I did. The ONLY allowed first level children inside a UL are LI tags.

Can ul be a child of UL?

Save this question. Show activity on this post. Element ul not allowed as child of element ul in this context.


2 Answers

The <ul> inside needs to be inside an li, so either make a new li or un-close the first one.

like image 197
meder omuraliev Avatar answered Nov 22 '22 06:11

meder omuraliev


The validator is correct: the only legal elements within a <ul> or <ol> element are <li> elements. If you want to nest lists, put them inside <li> elements.

like image 32
cletus Avatar answered Nov 22 '22 06:11

cletus