Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting font color of <a> inside a li tag

Tags:

css

My markup looks like:

<div class="c1">
      <li class="c2"><a href="">blah</a></li>
</div>

I want the text blah to be red.

c1 is used other places, so I want to drill down as much as possible without affecting other markup.

like image 300
mrblah Avatar asked Oct 18 '09 19:10

mrblah


People also ask

How do you change the color of text in a tag?

To set the font color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property color. HTML5 do not support the <font> tag, so the CSS style is used to add font color.

How do I change the font color on my HTML list?

To change the HTML font color with CSS, you'll use the CSS color property paired with the appropriate selector. CSS lets you use color names, RGB, hex, and HSL values to specify the color.

Which tag is used to change the Colour of the font?

The <font> tag in HTML plays an important role in the web page to create an attractive and readable web page. The font tag is used to change the color, size, and style of a text.


2 Answers

Use this style definition in your css-file:

div.c1 li.c2 a {
  color: red;
}

PS: Having your <li> tag inside your <div>-tag without an <ul>-tag is not recommended.

like image 103
Espo Avatar answered Oct 23 '22 20:10

Espo


<style>
  div.c1 li.c2 a { color: red; }
</style>
like image 25
Pointy Avatar answered Oct 23 '22 18:10

Pointy