Is :not(:hover) and :hover a safe way to hide accessible elements?

Your solution looks alright for CSS3. There isn’t anything I can think of to improve your solution for modern browsers as the opacity property will never be applied by browsers that don’t support it anyway. There is literally no other browser besides IE6 and NN4 (and older) without support for :hover on elements other than … Read more

Combining :not() selectors in CSS

Selectors level 3 does not allow anything more than a single simple selector within a :not() pseudo-class. As a jQuery selector, it works because jQuery extends its :not() functionality to allow any selector (like the .not() method). However, your second syntax is one of the proposed enhancements to :not() in Selectors 4, and works equivalently … Read more

CSS selector for attribute names based on a wildcard

As you have pointed out, there are multiple ways to target the value of an HTML attribute. E[foo=”bar”] an E element whose “foo” attribute value is exactly equal to “bar” E[foo~=”bar”] an E element whose “foo” attribute value is a list of whitespace-separated values, one of which is exactly equal to “bar” E[foo^=”bar”] an E … Read more

Get all css root variables in array using javascript and change the values

this script will return an array of root variables in all stylesheets, served from the domain. Out of domain stylesheets are not accessible due to CORS policies. Array.from(document.styleSheets) .filter( sheet => sheet.href === null || sheet.href.startsWith(window.location.origin) ) .reduce( (acc, sheet) => (acc = [ …acc, …Array.from(sheet.cssRules).reduce( (def, rule) => (def = rule.selectorText === “:root” ? … Read more

what does ::before really do?

::before and ::after refer to CSS pseudo-elements that are created before and after matching elements. Pseudo-elements are typically not shown in HTML element trees. However, if you are using the right kind of a debugging tool (like Chrome inspector) you can see these special elements. As its nowadays very common to style a page using … Read more

CSS use :not ID with CLASS

I believe that you are reversing the selectors. You have some elements with the same class, but you want to filter out an element with an specific ID. In that case: HTML: <p class=”someclass”>hello</p> <!– will be targeted by css below, thus green –> <p class=”someclass” id=”some-id”>hi</p> <!– will not be targeted by css below … Read more

How to select element by ‘role’ attribute and filter by class with vanilla JS?

Try this: // remove active class from all elements document.querySelectorAll(‘[role=”presentation”]’).forEach(function (el){ el.classList.remove(“active”); }); // add class ‘active’ to last element document.querySelectorAll(‘[role=”presentation”]:last-of-type’)[0].classList.add(“active”) Notes: ‘classList’ will not work in IE9; I think you have to modify adding class row, depending on your needs.