Remove ALL styling/formatting from hyperlinks
The property-value pair:
a {
all: unset;
}
seems cleaner in my opinion and has the advantage to work with all the selectors, e.g.:
a, button /* &c... */ {
all: unset;
}
To learn more about the all
shorthand, checkout this page: https://developer.mozilla.org/en-US/docs/Web/CSS/all
As Emi said, don't forget check for compatibility:
https://caniuse.com/css-all
You can simply define a style for links, which would override a:hover
, a:visited
etc.:
a {
color: blue;
text-decoration: none; /* no underline */
}
You can also use the inherit
value if you want to use attributes from parent styles instead:
body {
color: blue;
}
a {
color: inherit; /* blue colors for links too */
text-decoration: inherit; /* no underline */
}
As Chris said before me, just an a
should override. For example:
a { color:red; }
a:hover { color:blue; }
.nav a { color:green; }
In this instance the .nav a
would always be green, the :hover
wouldn't apply to it.
If there's some other rule affecting it, you COULD use !important
, but you shouldn't. It's a bad habit to fall into.
.nav a { color:green !important; } /*I'm a bad person and shouldn't use !important */
Then it'll always be green, irrelevant of any other rule.