Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude an Element (via ID) in CSS

Tags:

html

css

I have a CSS rule like * {-webkit-transition:all 0.7s ease}, This applies to all the elements on the page, but I want to exclude an Element from this rule with ID classic, how to do this?

like image 520
Akshat Mittal Avatar asked Aug 25 '12 08:08

Akshat Mittal


1 Answers

The CSS 3 pseudo class for excluding elements is :not. To exclude all elements matching #classic, but keep the rest, use

* :not(#classic) { 
  /* your definitions here */ 
}

See the W3C spec on selectors. Note that these CSS3 selectors don't work on all browsers, particularly older versions of Internet Explorer will happily ignore them.

like image 108
slhck Avatar answered Oct 26 '22 09:10

slhck