Are CSS selectors `:enabled` and `not(:disabled)` different from each other?

Are there any behavior discrepancies or variance in browser compatibility when comparing the usage of CSS3 selectors :enabled versus not(:disabled)?

I anticipate them to be essentially the same in functionality, and since they are both CSS3 selectors, I assume browser support would also be consistent across the board.

Answer №1

A distinction exists between :not(:disabled) and elements that are neither :enabled nor :disabled. This pertains to elements like div, p, ul, etc., where the enabled/disabled semantics do not apply.

The specification acknowledges this:

What defines an enabled or disabled state, as well as a user interface element, is specific to each language. In most documents, the majority of elements will not fall under either :enabled or :disabled.

Interestingly, there isn't a corresponding :unchecked pseudo-class for :checked, despite not all elements having checked/unchecked semantics either. More on this can be found in my response to this inquiry.

If you add a type selector (like input, select, or textarea) or a class selector to these pseudo-classes, the issue becomes less relevant. Nonetheless, it's advisable to opt for :enabled over :not(:disabled).

Most browsers exhibit identical support for the majority of level 3 pseudo-classes, with none exclusively supporting either :enabled or :disabled. However, MDN mentions that Opera 9.0 and Safari 3.1 may not endorse :not(), even though they do endorse :enabled and :disabled. Additionally, IE7 has limited support for substring-matching attribute selectors and the general sibling combinator ~, with slight improvements in IE8.

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

Establish a Zebra DataList Chart

My first task is to connect a Table from the database so that each row is editable. After some research, I settled on using the DataList due to its <EditItemTemplate> property, which the repeater lacks. To create a Zebra table, I crafted a CSS class ...

Not all the divs nested within the main div are having the class applied to them

Here is the HTML code I have: <?php require_once("../RMS/php/component.php") ?> <!DOCTYPE html> <html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-prot ...

What is the process for creating a sublist within an md-list-item using Angular Material?

I used Angular Material to create a md-list on the side-nav. I am looking to add a sub list under the md-list-item. Below is my code snippet: <md-sidenav id="sideNav" md-component-id="left" class="md-sidenav-left md-whiteframe-z1 md-locked-open " layo ...

Creating a mobile-friendly layout with 3 columns: Tips and tricks

I attempted to solve the issue independently but didn't have much success. My goal is to create a proper version for mobile users using bootstrap, however, it currently looks terrible on mobile devices. I suspect the problem lies with the div classes ...

Placing a point on a measurement scale according to a changing factor

I am completely new to html, css, and javascript. My goal is to create a color gradient bar and then place a dot on it based on a variable. I tried to implement a solution I found from various sources, but it is not functioning as expected, and I am seekin ...

What could be causing my jumbotron's background image not to appear?

Having trouble setting a background image for my jumbotron and nothing seems to be working. I've double-checked that my CSS comes after Bootstrap's CSS, and I've even attempted changing the file path. The image is stored in the correct fold ...

Tips on personalizing chosen date formats within the Mantine DatePicker?

I've integrated the Mantine DatePicker into my web application and now I want to customize the default style for when a user selects a date. Here's the current style: https://i.sstatic.net/hjQOi.png This is what I'm aiming for: https://i ...

Increase the space below the footer on the Facebook page to allow for an

I recently created a webpage at and noticed that it is adding extra height below the footer on my Facebook page: "" I am seeking assistance on how to remove this additional 21px height below all content in the footer. I have tried various templates but n ...

Ensure that the video is properly positioned within the background when utilizing the background-size cover property

I am currently working on a project that requires me to position a video clip on a specific section of the background image, ensuring that the video always appears on top of the phone's screen. The responsive background image is constantly changing. H ...

The elements from base.html and the extended page are now placed on separate rows rather than on the same row

I'm relatively new to HTML, Jinja, and CSS and have been playing around with creating a webpage that retrieves data from a sqlite3 database. As of now, I am facing some challenges regarding formatting. To assist with table formatting and overall aest ...

HTML: Body with a larger height than its actual content dimensions

My Chrome browser extension seems to have a body that is much taller than its actual content: https://i.sstatic.net/t44t6.pnghttps://i.sstatic.net/8WjzD.png Even though there are no other parent div elements, the height of the <div id='app'& ...

JavaScript Logic to Check if an Element is Hidden

I'm having trouble figuring out how to close an element when another element collapses. I've searched for solutions without success. My structure is updated using Bootstrap and JavaScript, but it doesn't function as expected. Specifically, ...

Is it possible to implement a hover animation within another hover animation in WordPress?

Trying to incorporate two hover animations for the images in my photo galleries. When hovering over an image, I want a text to appear in a black overlay, and then when hovering over that text, it should become underlined. Looking for something similar to ...

Setting Aggrid style height to 100% in JustPy made easy

I am attempting to adjust the Aggrid height style to 100%, but unfortunately, the table is not displaying as expected. I have tried using viewport and pixel measurements, which worked fine. Interestingly, percentage width is working perfectly well. My goa ...

The popup is unable to remain in the center of the screen because the background page keeps scrolling back to the top

Whenever I click a button to open a popup window, the page unexpectedly scrolls to the top. It's frustrating because if I'm at the bottom of the page and press the 'submit' button, the popup doesn't display in the center as intende ...

Altering the background color of the navigation bar when scrolling

So, my navigation bar starts with a transparent background, but I wanted it to change to a different background color when a user scrolls down. I found a solution in this question: Changing nav-bar color after scrolling? My current code now looks like th ...

Adding a border to my image that extends to the edges of the page

.overlay{ position:absolute; top:0; left:0; height:100%; width:100%; background:url(hex-shape.png) no-repeat center; z-index:99999; } I have created an overlay background image that covers the entire page. I want the area surrounding the ove ...

Align the logo in the center of the navbar with items placed on either side

Looking for a way to center my brand logo within my navbar with menu items positioned around it? Preferably without the use of javascript? I've tried different methods, including adjusting the Bootstrap navbar styling, but haven't found a perfect ...

Having trouble with this code// Does anyone know how to make the div slide in line with other divs when hovering over it?

After spending countless hours analyzing and trying various solutions, I have come to the realization that I need to seek help with my code. The task at hand is proving to be incredibly frustrating, and I have exhausted all other options before resorting t ...

Is it possible to revert the text back upon double-click or when it loses focus?

When I click on a dropdown labeled 'View Capacities', the label changes to 'Hide Capacities'. I am attempting to make it change back to the original label when it is double clicked (when toggle closes) or when the user clicks elsewhere ...