Implement a style to all elements except for the special element

Learn HTML

<ul id="tree">
    <li>
        <label>
            <input type="checkbox" /> Level 1 - 1</label>
    </li>
    <li>
        <label>
            <input type="checkbox" /> Level 1 - 2</label>
        <ul>
            <li>
                <label>
                    <input type="checkbox" /> Level 2 - 1</label>
                <ul>
                    <li>
                        <label>
                            <input type="checkbox" /> Level 3 - 1</label>
                    </li>
                    <li>
                        <label>
                            <input type="checkbox" /> Level 3 - 2</label>
                        <ul>
                            <li>
                                <label>
                                    <input type="checkbox" /> Level 4 - 1</label>
                            </li>
                        </ul>
                    </li>
                </ul>
            </li>
        </ul>
        <li>
            <label>
                <input type="checkbox" /> Level 1 - 3</label>
        </li>
        <li>
            <label>
                <input type="checkbox" /> Level 1 - 4</label>
        </li>
    </li>
</ul>

CSS Styling

* :not(#tree){padding:0px}

The author wants to set padding to zero for all elements except #tree. However, the code * :not(#tree){padding:0px} ends up setting padding zero for li, label, and input elements as well. How can we exclude child elements of #tree from having padding zero?

Reference: Original jsfiddle link and desired outcome: Updated version

Answer №1

Give this a shot:

:not(#plant)
{
    margin:0px;
}

This code specifies that the margin: 0px should be applied to all elements except those within #plant

For a more in-depth understanding of how the :not command functions, check out the following page:

http://www.example.com/css/not-command

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

unable to retrieve the data from the secondary dynamic cascading dropdown menu

Hopefully, my day's troubles will be resolved by now. I am facing an issue with two drop-down boxes. After submitting, only the value of the first dropdown box is available in the action page. The second dropdown box is dependent on the selection made ...

Interactive mobile navigation featuring clickable elements within dropdown menus

I recently implemented a mobile nav menu based on instructions from a YouTube tutorial that I found here. Everything was working perfectly until I encountered an issue on the 'reviews list' page. The dropdown in the mobile nav is supposed to be ...

I am unable to correctly fetch the data string using Jquery Ajax from the server

I have implemented a jQuery Ajax function to check the availability of a username in real-time from the database. If the username is not available, the response is marked as "Unavailable" and vice versa. While I am successfully receiving this response, I a ...

One CSS file linked, but only one is applied; the other is left unused

After including two CSS files, I am experiencing an issue where only one of them is being utilized. The other file does not seem to be included and the reason behind this remains unknown. My website has a standard header file that is present on all pages. ...

How can one display blog data (stored as a PDF) from a database alongside other different results (stored as

I have successfully displayed a PDF file from my database as a blob using the header("Content-type:application/pdf") method. Now, I am looking to also display some additional string results along with this PDF file. Is it feasible to achieve this while d ...

Expansive Carousel Feature with Ng Bootstrap

In my Angular 5 application, I am utilizing the Carousel component from "@ng-bootstrap/ng-bootstrap": "^1.1.2". I am trying to display pictures in full screen but when I press F11, the image appears like this. I am unsure of which CSS properties to apply ...

Creating mobile-friendly websites for a variety of devices, including smartphones and tablets

Creating a prototype webpage for my friend, one crucial aspect is ensuring it looks good on different devices. Utilizing Bootstrap, I've implemented vertical collapsing for certain elements, but I'm struggling with how to adjust other components ...

Is it feasible to embed Instagram in an iframe without using the API?

Is there an alternative method to embed Instagram using iframe without the need for an API? ...

What is the best way to track ScriptService WebService requests?

I am facing an issue with my SoapExtension, which is designed to log SOAP requests and responses. It functions correctly for calls made from an application using the MS Soap Toolkit (OnBase Workflow). However, it does not work for calls initiated by $.ajax ...

Checkbox option to change background color of table cell

$('#selectall1').click(function(event) { if (this.checked) { $('.first').each(function() { this.checked = true; }); $('.second').each(function() { this.checked = false; }); $('.third&apos ...

Issue with IE6: Div inside Anchor element causing inline images to not be clickable links

I am currently facing an issue where I need everything within the anchor tag to be a clickable link, but in IE6 (the only browser I am concerned about at the moment), the inline images are not clickable. I understand that it is not valid HTML to place a di ...

Error: Unable to call topFrame.window.changeSelectedBarStyle because it is not a valid function. What could be causing this

This function is called changeSelectedBarStyle: function changeSelectedBarStyle(tdId){ $("#menuTable td").each(function(index){ if(this.id == tdId){ $(this).removeClass("menuPanel"); $(this).addClass("menuPanelSelected" ...

Modify the color of the downward arrow within a dropdown menu

I'm currently working with ngx paginator and I need to customize the CSS styles to appear in white color. Here is the code I've tried: HTML <div class="paginator__footer-select col col-md-3 offset-md-1 "> & ...

Recommendation: 3 options for radio buttons on the registration form

My form includes a section where users need to choose if they want to sign up for a session that occurs 3 times daily. The catch is, only 5 applicants can enroll in each session (AM, Mid-day, PM). It's a competition to secure a spot. Here is the form ...

Having trouble getting my Leaflet map to display even after meticulously following the quick-start guide

I am experiencing an issue where the map is not displaying at all, leaving a blank space where it should be. Despite following Leaflet's quick-start guide, I have been unable to determine the cause of this problem. Here is the code that I currently h ...

Navbar transition issue in Bootstrap

Having trouble with Bootstrap transitions not functioning correctly on my navbar. The issue is when I click the dropdown button in the navbar, the hidden elements appear abruptly without any transition effect. Below is the HTML code being used: <!do ...

Utilizing a promise instead of making a jQuery ajax request

A scenario I am facing involves a function that is set to execute jquery.ajax and return it as a promise for future processing. However, in certain cases, the function possesses enough information to proceed synchronously without triggering the ajax call. ...

Aligning object in middle of a responsive image using Bootstrap

I'm having trouble centering a button on an image using responsive design techniques. I am currently utilizing Bootstrap 3 and have attempted to use CSS margin properties to center the button, but this method is not ideal especially on smaller screens ...

javascript various backgrounds on click

I have implemented a list to allow users to select their top 3 choices, and I am using JavaScript to track these selections and change the background color accordingly. 1st selection -> Green background 2nd selection -> Yellow background 3rd sel ...

The results of running 'npm run dev' and 'npm run build prod' are different from each other

Currently, I am in the process of developing a progressive web app using Vue.js. During development, I utilize the command npm run dev to initiate the local server that serves the files over at http://localhost:8080/. When it comes time to build for produ ...