You are viewing the article How to Change Text Color in HTML at Lassho.edu.vn you can quickly access the necessary information in the table of contents of the article below.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 46,997 times.
Although you can change the text color using the <font> tag in HTML, this is no longer supported on HTML5. Instead, you should use basic CSS to define the colors that text should display in different elements on the web page. CSS will also make sure your site is cross-browser compatible.
Steps
Using CSS
- This also works quite well with separate stylesheets (CSS files embedded in HTML). The examples below are for HTML file with stylesheet insertion.
<!DOCTYPE html> < html > < head > < style > </ style > </ head >
<!DOCTYPE html> < html > < head > < style > body { } </ style > </ head >
<!DOCTYPE html> < html > < head > < style > body { cpor : } </ style > </ head >
<!DOCTYPE html> < html > < head > < style > body { cpor : red ; } </style> < / head > _
<!DOCTYPE html> < html > < head > < style > body { cpor : red ; } h1 { cpor : #00FF00 ; } p { cpor : rgb ( 0 , 0 , 255 ) } </ style > </ head > < body > < h1 > This heading will be green. </ h1 > < p > This paragraph will be blue. </ p >
This content will be red.
</body> < / html > _
<!DOCTYPE html> < html > < head > < style > . redtext { cpor : red ; } </ style > </ head > < body > < h1 class = "redtext" > This heading will be red </ h1 > < p > This paragraph will display normally. </ p > < p class = " redtext" > This paragraph will be red </ p > </body> </ html >
Using the inline style attribute
<!DOCTYPE html> < html > < body > < h1 > This is the heading you want to change color </ h1 > </ body > </ html >
<!DOCTYPE html> < html > < body > < h1 style = "" > This is the heading you want to change color </ h1 > </ body > </ html >
<!DOCTYPE html> < html > < body > < h1 style = "cpor:" > This is the heading you want to change color </ h1 > </ body > </ html >
<!DOCTYPE html> < html > < body > < h1 style = "cpor:#FFFF00;" > This heading will now be yellow </ h1 > </ body > </ html >
Advice
- You can see a list of supported color names and hex values at http://www.w3schops.com/cpors/cpors_names.asp
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 46,997 times.
Although you can change the text color using the <font> tag in HTML, this is no longer supported on HTML5. Instead, you should use basic CSS to define the colors that text should display in different elements on the web page. CSS will also make sure your site is cross-browser compatible.
Thank you for reading this post How to Change Text Color in HTML at Lassho.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: