I have this CSS:
a { color:#19558D; padding:3px 5px; text-decoration:none; } a:hover { background-color:#D1E1EA; color:#19558D; text-decoration:none; }
It applies to all links, but what if I don't want it to apply to a specific link on the page? What can I do?
In CSS, to exclude a particular class, we can use the pseudo-class :not selector also known as negation pseudo-class or not selector. This selector is used to set the style to every element that is not the specified by given selector. Since it is used to prevent a specific items from list of selected items.
Press TAB to highlight the element, and then click to select it. In the drawing area, click the icon ( ) to exclude the element, or right-click, and click Exclude.
The CSS id Selector The id of an element is unique within a page, so the id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element.
There are two ways you can do this.
First way is to use the :not()
selector and give your link that you don't want the styles applied to class:
a:not(.unstyled):hover { background-color:#D1E1EA; color:#19558D; text-decoration:none; }
However, the :not()
selector is not supported in IE8 or less, so the second option is to give your unstyled links a class, and override those properties for that link with that class:
a.unstyled:hover { background-color:none; color:#000 text-decoration:none; }
You can apply your own class or inline style to the link in question.
for example:
<a href="#" class="MyNewClass" />
or
<a href="#" style="color:red;" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With