limitphp Posted December 7, 2012 Share Posted December 7, 2012 If I have a section of text in a table or div, or something else, and I just want to change the font color of one word in the text, what is the correct tag to use to change the font color? I understand I should use the style='color:', but what tag is the most appropriate for this? Link to comment https://forums.phpfreaks.com/topic/271726-what-is-correct-tag-to-use-to-change-fonts/ Share on other sites More sharing options...
MDCode Posted December 7, 2012 Share Posted December 7, 2012 <font color="blah">word</font> Link to comment https://forums.phpfreaks.com/topic/271726-what-is-correct-tag-to-use-to-change-fonts/#findComment-1398146 Share on other sites More sharing options...
kicken Posted December 7, 2012 Share Posted December 7, 2012 (edited) <font color="blah">word</font> No, <font> has been deprecated for a while, and is no longer valid in html5. @limitphp You should use CSS to apply the font you need to the element containing your text. The element you use should be sematic for whatever the text represents/means on the page. If you need a generic element to wrap a small bit of text, use <span> or <div> depending on if you need inline or block level elements. Edited December 7, 2012 by kicken Link to comment https://forums.phpfreaks.com/topic/271726-what-is-correct-tag-to-use-to-change-fonts/#findComment-1398149 Share on other sites More sharing options...
limitphp Posted December 7, 2012 Author Share Posted December 7, 2012 <font color="blah">word</font> I thought html 5 has gotten rid of the font tag. I understand it still works in browsers, but is that really the appropriate tag to use? Is there a tag that would be more in line with the new standards? Link to comment https://forums.phpfreaks.com/topic/271726-what-is-correct-tag-to-use-to-change-fonts/#findComment-1398150 Share on other sites More sharing options...
limitphp Posted December 7, 2012 Author Share Posted December 7, 2012 No, <font> has been deprecated for a while, and is no longer valid in html5. @limitphp You should use CSS to apply the font you need to the element containing your text. The element you use should be sematic for whatever the text represents/means on the page. If you need a generic element to wrap a small bit of text, use <span> or <div> depending on if you need inline or block level elements. Div would knock the text after it down on the next line, unless I added some style properties to the div. So, perhaps span is the best tag to use to change the font of one word in a section of text? Link to comment https://forums.phpfreaks.com/topic/271726-what-is-correct-tag-to-use-to-change-fonts/#findComment-1398151 Share on other sites More sharing options...
Jessica Posted December 7, 2012 Share Posted December 7, 2012 Span is probably best, but you can always use display: inline; to make a block element (div, p) look like a span does. Link to comment https://forums.phpfreaks.com/topic/271726-what-is-correct-tag-to-use-to-change-fonts/#findComment-1398177 Share on other sites More sharing options...
Recommended Posts