How to deselect with CSS?


Tags: css,css-selectors

Problem :

i would like to deselect and #id item from a selection without changing HTML or adding any classname,

lets say i want to emulate this Jquery sentence in CSS

 $('img').not('#thisone').CSS();

is it possible?



Solution :

Use CSS3's :not() selector (which has an equivalent jQuery selector):

img:not(#thisone) {
}

If you need better browser support, there's always the fact that ID selectors, being the most specific simple selectors, are good for overrides:

img {
    /* All images */
}

#thisone {
    /* Revert styles for this particular image */
}

    CSS Howto..

    How to style an add to cart

    How to do CSS attribute selector with title~= that has to contain a space?

    how do i change button/image onclick to active state?

    How to display text on the same line?

    CSS select + select How to get first select

    How to load self hosted font files if the GoogleFont service is unavailable?

    javascript - how to get date locale to work?

    How can I change the text decoration on numbers only on my web page?

    How to move/position DIV container by changing CSS values using Javascript?

    How to get ID from CSS to Javascript without getElementByID?

    Weird CSS effect with box shadows - how to solve?

    How to toggle div and up-down arrow heads using css only

    In IE Compat View, Developer tools shows elements “style” with the class of the previous element

    How can I force an image to display in its entirety with CSS?

    how to to set chat box based on user id using css

    How do I vertically align multiple text next to an image with CSS?

    How to change
  • to variable width on css dropdown submenu
  • How to make css styles in the document body only specific to a div

    How to create a label inside an element and style it?

    How to use Bootstrap Glyphicons in Holder.js images

    angular ngShow with animate.css

    CSS : How to make two column right fluid left fluid depend on right

    how to make dropdown using html and css?

    How to add CSS to my HTML code on Notepad++

    How do I make the text in the next line to be centered and not aligned to the left?

    How to select two elements with “> span” in CSS?

    How to lessen CSS

    How to expand textarea to fit text vertically and horizontally?

    how does responsive design work?

    Any Idea how this web site acheives a fluid/liquid layout [closed]