Algebreaker
Algebreaker

Reputation: 118

Changing the colour for a specific hyperlink in html5/CSS

I'm really sorry if this is basic stuff- I'm new to html and style sheets and I've googled around for a while, but so far haven't found an answer to my question: I'm writing a single-page website where the subsections have different background colours and I have specified the colours for a, a.hover and so forth in my style sheet, eg.

a { color: #48A3A6; text-decoration: none;}

However For one of the subsections I need my hyperlink to have a different font colour. How can I achieve this? Specifying a different text colour doesn't seem to work, as it's not text and I don't want to change the hyperlink colour for the entire webpage.

Thank you!

Upvotes: 1

Views: 72

Answers (1)

Tomer Almog
Tomer Almog

Reputation: 3868

Assign a class or an id to your tag and than crate a selector for it in your css. You can also do achieve that with inline style but it is not a best practice: class:

HTML:

<a class="my-class">Link</a>
<a id="my-id">Link</a>
<a style="color:#000;">Link</a>

CSS:

.my-class{
    color:#000;
}
#my-id{
    color:#000;
}

will all achieve the same result

Upvotes: 1

Related Questions