CSS does not seem to support nesting list elements within other list elements

<ul>
     <li>One
          <li>two</li>
     </li>
</ul>

Attempted to target the second <li> with:

li li {
    background: "red";
}

Questioning the reason for it not functioning as expected.

Answer №1

It seems like you missed including one ul element in your HTML code, and the document is not valid HTML5. A correct way to nest lists would be:

<ul>
     <li>This
         <ul>
             <li>and this</li>
         </ul>
     </li>
</ul>

In your CSS file, you can style the nested list items with a background color like this:

ul li ul li {
    background: "red";
}

For further information on creating properly nested HTML lists, you can visit Proper way to make HTML nested list?

Hope this solution helps! Best regards.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Modifying the content of a webpage with the help of Tampermonkey

I'm working on changing a W Text into B using the code below. It's functional, but I'm experiencing two issues. First, there is a lag when refreshing the page where it briefly shows the W text before replacing it with a B. Second, every 20 o ...

Achieve perfect alignment with CSS grid and maintain it as you expand your layout

I'm trying to include images along with explanations. Intended outcome: https://i.sstatic.net/B90hB.png https://i.sstatic.net/LTp2j.png https://i.sstatic.net/QvIux.png Current disappointing result: (not centered) https://i.sstatic.net/gFXZP.png h ...

How to eliminate spacing on the left side of a Bootstrap button

Why is there a space before my first button and how can I remove it? <div class="container"> <div class="row"> <div class="col-xs-4 col-md-3"> <button @onclick="ShowModal" class="btn btn-primary"><i class="oi oi-plus ...

What is the best way to reveal the menu options by tapping on the top left icon?

Seeking guidance on how to activate the menu by clicking the top left corner icon. A sample code setup is available in Codepen through this link: https://codepen.io/RSH87/pen/rmgYbo. I require assistance with incorporating the JavaScript file into my React ...

Assign a variable name to the ng-model using JavaScript

Is there a way to dynamically set the ng-model name using JavaScript? HTML <div ng-repeat="model in models"> <input ng-model="?"> </div JS $scope.models= [ {name: "modelOne"}, {name: "modelTwo"}, {name: "modelThree"} ]; Any ...

Updating the Three.js Raycaster following CSS transformation

I am new to diving into the world of WebGL with Three.js. As a beginner, I wanted to experiment with something similar to this. I've managed to get most of it working, but I'm currently struggling with updating the raycaster and object after shif ...

Guide on making a half circle within a container or a button aligned with text

I'm struggling with designing a half circle inside a button that is centered inline with the text. Can someone please assist me with this? On this particular scenario, what would be more suitable - using a button element or styling a div to look like ...

Troubleshooting a jQuery Drop-Down Problem

My dropdown menu is not working as expected. I want to show the sub-menu when clicking on an item, and remove the previous sub-menu when clicking or blurring on another menu by removing the drop-down class. However, my current jQuery code does not seem to ...

The children of the <Grid item> component in material-ui are overlapping the parent because they have a width of 100%

One issue I'm facing is that when I have children with full width in a Grid item, they end up overlapping to the right side of their parent. To illustrate this problem, here's the code: https://codesandbox.io/s/rn88r5jmn import React, { Compo ...

Using FQL and HTML, create a unique Facebook PHP SDK Birthday Application

I am using an FQL query to retrieve birthdays of user's friends. My aim is to organize the users based on their birth month and day, so that all birthdays in a specific month are grouped together within a div element with an ID representing the first ...

Apply bold formatting to the HTML text only, leaving the EJS variable untouched beside it

https://i.sstatic.net/X36eG.png Is there a way to format the text for "Guest signed up" and "Guests attended" in bold while keeping the values normal? Here is my current code: <li class="list-group-item">Guests signed up: <%= guestSignu ...

Unusual Glitch in Bootstrap 3 Dropdown Menu

I am currently developing a website using Bootstrap 3. I am encountering an issue with the navbar dropdown. When I click on the link, it changes to show "expand child menu" and "collapse child menu". To clarify, here is the image I am referring to: Initi ...

ESP32 - Creating a dynamic webpage using a webserver

I am using an ESP32 configured as a webserver. I have multiple webpages that are included as files, such as index.h const char MAIN_page[] PROGMEM = R"=====( <!DOCTYPE html> <html> some divs here.... </html> )====="; The conten ...

Tips for aligning a text box in the center using Bootstrap

Is it possible to easily center the input text box of bootstrap? <form action="#" method="post" class="akame-contact-form border-0 p-0"> <div class="row justify-content-center"> <div class= ...

designing items in various color palettes

section { background-color:#d5ecf2; width:1024px; height:200px; margin: 0 auto; } .sectiontext { float:right; height:180px; width:720px; margin:10px; } <section> <div class="sectiontext"> <h3>GDS 114.01: HTML and Javascript</h3 ...

The align-self-center property in Twitter Bootstrap Flex does not properly center elements vertically

I recently started working with twitter bootstrap 4.4.1 and flex to create a unique layout for my project. My main goal is to have a navbar at the top and the content displayed in the middle of the screen, as shown in the image here: https://i.sstatic.net ...

Pressing the enter key will submit the form

After receiving feedback from users in my live chat room, one common request was to add a feature that allows them to send a message by pressing the enter button, instead of creating a new line in the text box. Despite attempting to implement some jQuery ...

Error message: ASP.Net Update Panel unable to access global variables in code-behind

I have been working on updating a bootstrap progress bar's percent on my website. While I understand that ajax is the recommended method for this, I attempted to achieve this without using ajax and was able to make some progress. Below is the code sn ...

Is anyone else experiencing differences in the appearance of my mega menu between Safari, Firefox, and Chrome? It seems like

When viewing in Safari, the text overlaps for some reason. It works fine on Firefox and Chrome. Here's a screenshot of the issue: Safari: https://i.stack.imgur.com/hf7v2.png Firefox: https://i.stack.imgur.com/NrOOe.png Please use Safari to test th ...

Center the Search Form for improved visibility

As a novice web developer, I am in the process of building a website similar to LinkedIn using Bootstrap-4. My current challenge is how to center my form within the navbar. Below is a snippet of the code from my webpage: <body> < ...