Background Color
Có thể bạn quan tâm
This page contains HTML background color code. Using this code, you can add a background color to any HTML element.
To add background color to an HTML element, you need to use the CSS background-color property. You can also use the background property, which allows/requires you to add other background related properties at the same time.
Here are some examples of applying background color to an HTML document.
The background-color Property
The CSS background-color property allows you to apply background color to an HTML element. In the following example, we apply background color to a div element. To demonstrate the example, we place some text within the <div> element and color it black. We also add a black border around the <div> using the border property.
Source Code | Result |
---|---|
HTML background color example | HTML background color example |
Text and Background Color
You aren't limited to applying background color to the div element. You can apply it to any HTML element. For example, background color is sometimes applied to a large or small section of text. You can use the <span> element to pick a section of your text to highlight with a different color.
Example:
Source Code | Result |
---|---|
HTML text background color example | HTML text background color example |
The background Property
As mentioned, the CSS background property allows you to add all your background related properties all in one go.
This is more efficient, especially if you're applying many background properties.
Here's an example of using the background property.
Source Code | Result |
---|---|
HTML background image example | HTML background image example |
Background Images
You can also apply background color by using a background image. This will also allow you to add some "texture" to your background color, or even a background pattern. But even if you do use a background image, it's good practice to use a background color as well. This ensures that, in the event your background image can't be displayed, the background image will still display.
Từ khóa » Html Color Text Background
-
HTML Styles - W3Schools
-
Background Color - Tryit Editor V3.7
-
Change HTML Background Color Or Font Color - BitDegree
-
How To Add & Change Background Color In HTML - HubSpot Blog
-
Html - How Do I Set A Background-color For The Width Of Text, Not The ...
-
Font Colors And Backgrounds - HTML Test Suite For UAAG 1.0 (Draft)
-
In HTML, How Do I Change The Color Of The Text And Background Of A ...
-
HTML Colors, Text, Background And Border
-
HTML Text Color - HTML Color Codes
-
HTML Color Code For Background And Text On Web Page
-
#FFFFFF (White) HTML Color Code - Computer Hope
-
How To Highlight Text In Color Using HTML And CSS - Computer Hope
-
Background-color - CSS: Cascading Style Sheets - MDN Web Docs