Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7506697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:20:03+00:00 2026-05-29T22:20:03+00:00

Any idea why ‘li’ elements are not inheriting ‘p’ elements style in the following

  • 0

Any idea why ‘li’ elements are not inheriting ‘p’ elements style in the following snippets?
i.e ‘role1’ and ‘role2’ are rendering as black while ‘Hello world!’ and ‘Inside nested p’ are in blue.

<!DOCTYPE html>
<html>
    <title>test</title>
    <head>
        <style type="text/css">
        p {
            color: blue;
        }
        </style>
    </head>
    <body>
        <p>
            Hello World !
            <ol>
                <li>role1</li>
                <li>role2</li>
            </ol>
            <p>
                Inside nested p
            </p>
        </p>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:20:04+00:00Added an answer on May 29, 2026 at 10:20 pm

    The p tag can not contain block level elements.
    So the browser automaticaly closes the p tag for you.
    Your html will parse like this:

    <!DOCTYPE html>
    <html>
        <title>test</title>
        <head>
            <style type="text/css">
            p {
                color: blue;
            }
            </style>
        </head>
        <body>
            <p>
                Hello World !
            </p>
                <ol>
                    <li>role1</li>
                    <li>role2</li>
                </ol>
                <p>
                    Inside nested p
                </p>
        </body>
    </html>
    

    And now you see why Hello world and Inside nested p are blue and the li elements are not

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any idea why the following mocking code does not work? org.hibernate.SessionFactory sessionFactory = Mockito.mock(SessionFactory.class);
Any idea why the following code will not compile? IEnumerable users; using (var ent
any idea how if the following is possible in PHP as a single line
Any idea why the following code doesn't print the amount of characters in the
Any idea why my web page content doesn't resize with the window? I'm not
Any idea why the following query syntax is wrong: SELECT year, sum(profit) FROM BASEDATA
Any idea where the setting is hiding for turning gridlines off while using excel
Any idea why the piece of code below does not add the script element
Any idea if there is a way to make the following code to work
Any idea about cp: cycle detected: Error on Solaries. I am getting this while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.