After years of using the <a>
tag I've never found an answer to a long-asked question.
To crack down on the stylings of a <a>
tag I usually apply four styles:
.element:link{text-decoration:none;color:#CCC;}
.element:hover{text-decoration:none;color:#CCC;}
.element:active{text-decoration:none;color:#CCC;}
.element:visited{text-decoration:none;color:#CCC;}
Because as most of you probably know, browsers tend to apply a default underline and royal blue colour to links.
When I say What is the bare minimum styling for a element is there a way I don't have to apply all of these styles? Will the :hover
, :active
and :visited
inherit the :link
style? and is it compatible across all browsers?
P.S.
I know that the above is the same as
.element:link, .element:hover, .element:active, .element:visited{text-decoration:none;color:#CCC;}
So please don't answer with that (:
<a>: The Anchor element. The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address. Content within each <a> should indicate the link's destination.
CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section.
The <style> tag is used to define style information (CSS) for a document. Inside the <style> element you specify how HTML elements should render in a browser.
The <style> element must be included inside the <head> of the document. In general, it is better to put your styles in external stylesheets and apply them using <link> elements.
The bare minimum is no styling at all -- so that the browser will automatically apply its default styles.
The usual default is indeed royal blue for link, red or purple for visited, and nothing in particular for the rest.
Answered because @Rob said I should put it here
a.element{}
or
.element {}
You just use
.element {text-decoration:none;color:#CCC;}
and that's it.
If you want to additionally style :hover
or :active
state, you do it after .element {}
If you want it to apply to all your links, you can use
a {text-decoration:none;color:#CCC;}
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