How To Change Text Color In Html - Linux Hint
Có thể bạn quan tâm
How to change text color using <font> tag
The <font> tag is used to change not only the text color but also the font size and the font face. This tag was used in previous versions of HTML and is depleted from HTML5. This is because using this tag makes the procedure of styling elements hectic. You have to specify this tag for every element for every other web page.
HTML
<!DOCTYPE html> <html> <head> <title>Change Text Color in HTML</title> </head> <body> <font color="red"> <h1>Linux Hint</h1> </font> <font color="blue"> <p>Changing text color in HTML</p> </font> </body>In the above code, we have defined an <h1> and <p> element and using the <font> tag the text color of the heading has been set to red, meanwhile, the text color of the paragraph is assigned blue color.
Output
The color of the text was changed successfully.
How to change text color using the style attribute
The approach that is preferred over using the <font> tag is the usage of the style attribute. This method is shown in the code given below.
HTML
<!DOCTYPE html> <html> <head> <title>Change Text Color in HTML</title> </head> <body> <h1 style="color: purple;">Linux Hint</h1> <p style="color: red;">Changing text color in HTML</p> </body>In the code snippet above, we are using the style attribute of each of the elements generated above. Using this attribute the text color of the heading was set to purple, whereas, the paragraph was given a red text color. This attribute gives an inline style to elements.
Output
The style attribute is working properly.
Following the approaches mentioned above, you can easily change the text color in HTML.
Conclusion
In order to change the text color in HTML either use the <font> tag or use the style attribute. The <font> tag is, however, deleted from HTML5 because using this tag makes the procedure of styling elements hectic. You have to specify this tag for every element for every other web page. Meanwhile, the style attribute gives an inline style to elements, therefore, this approach is preferred over the former.
Từ khóa » Html Color Text Style
-
HTML Styles - W3Schools
-
HTML Font Tag - W3Schools
-
HTML Font Style – How To Change Text Color And Size With An ...
-
How To Set Font Color In HTML? - Tutorialspoint
-
HTML Text Color - HTML Color Codes
-
How To Change Font In HTML - HubSpot Blog
-
HTML | Color Attribute - GeeksforGeeks
-
How To Change Text Color In Html - Javatpoint
-
How To Change The Font Type, Size, And Color On A Web Page
-
How To Change The HTML Font Color - Kinsta
-
Change HTML Background Color Or Font Color - BitDegree
-
HTML Font Color Attribute
-
5.1 Font Color | R Markdown Cookbook - Bookdown
-
CSS Code Example For Font Color (And Why HTML Is Forbidden) »