Sam
Sam

Reputation: 111

Correct method for changing text color - CSS, <span>, <font>?

Assuming I want to change the color of a single word within a paragraph.

My options seem to be: External, Internal or Inline CSS, <font> or <span>.

What's the correct method?

Upvotes: 0

Views: 110

Answers (2)

Alex Green
Alex Green

Reputation: 70

'font' may be deprecated in the near future so 'span' is the better option of the two because of that reason alone.

Always best to use external styles. Maybe add a class to your span, then you can use it again and again.

Most importantly, decide why you are adding colour to the text, if it is to emphasise a word, it would be best to use 'em' and style that using your stylesheet. If a user was blind, they would not see the colour but they would hear the 'em' when it is being read.

Upvotes: 0

Quentin
Quentin

Reputation: 944204

  1. Decide why you want to change the font colour.
  2. Select the element which describes that reason the best (<em> if you are doing it for emphasis, <body> if you are doing it globally, etc). Add classes to existing elements if you need distinguish between two elements of the same type (i.e. be more specific about the reason than the type of element allows by itself).
  3. Write a selector in your stylesheet that matches that element.

Upvotes: 2

Related Questions