Aquarius24 Aquarius24 - 6 months ago 18
HTML Question

Hyperlink color not changing

I am trying to set colour of hyperlink to white in paragraph, but still it is not changing

<p style="color: rgb(255, 255, 255); a {color: rgb(255, 255, 255)};"><
Open Now <a href="http:mylink">Apply now!</a></p>

Answer

If you are going to use inline styles you should have it like this:

<p style="color: rgb(255, 255, 255); background: green;">
  Open Now <a href="http:mylink" style="background: black; color: rgb(255, 255, 255);">Apply now!</a>
</p>

Background color was added in the example for being able to see the hyperlinks.

EDIT:

Just to make it clear if it was not already you should avoid inline styles if possible. You should use Style Sheets in HTML documents

So the above example with a css file would be (style.css):

p {
  background: green;
  color: rgb(255,255,255);
}

a {
  background: black;
  color: rgb(255,255,255);
}

Then include your css file in the <head> of your document like this assuming you would call your css file style.css and it would be located in your project root (same level as index.html) in a folder named "css":

<!DOCTYPE html>
<html>
  <head>
    <link href="css/style.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <p>
      Open Now <a href="http:mylink">Apply now!</a>
    </p>
  </body>
</html>
Comments