HTML Background-color - Javatpoint
Có thể bạn quan tâm
next → ← prevHTML Background-color
Next TopicHTML Date← prev next →
The <bgcolor> is the attribute to set the background color of an HTML element. This attribute is used with the following tags:
- <body>
- <table>
- <marquee>
- <td>
- <th>
- <tr>
Syntax
<"tag" bgcolor="Color_name|rgb number|Hex number">Examples: The following examples use the <bgcolor> attribute in the different tags.
Example 1: Use the <bgcolor> attribute with the <body> tag
<!DOCTYPE html> <html> <head> <title> Example of Background color Attribute </title> </head> <body bgcolor="lightblue"> <!-- The attribute bgcolor use with the body tag to set the background of web page as lightblue --> <center> <h1> javaTpoint</h1> <br> <br> <center> <h2> Hyper Text Markup Language </h2> </center> </body> </html> Test it NowOutput:
Example 2: Use the <bgcolor> attribute with the <tr> tag
<!DOCTYPE html> <html> <head> <title> Example of Bgcolor Attribute </title> </head> <body bgcolor="red"> <!-- The attribute bgcolor use with the 'body' tag to set the background of web page as red --> <center> <h1> javaTpoint</h1> <br> <br> <center> <table> <!-- The attribute bgcolor use with the 'tr' tag to set the background of table rows by different colors --> <tr bgcolor="blue"> <td> Roll No. </td> <td> Name </td> </tr> <tr bgcolor="lightblue"> <td> 101 </td> <td> Abhay </td> </tr> <tr bgcolor="brown"> <td> 102 </td> <td> Chetan </td> </tr> <tr bgcolor="orange"> <td> 103 </td> <td> Manpreet </td> </tr> <tr bgcolor="yellow"> <td> 104 </td> <td> Rakesh </td> </tr> <tr bgcolor="lightgreen"> <td> 105 </td> <td> Sumit </td> </tr> </table> </center> </body> </html> Test it NowOutput:
Example 3: The following example use the <bgcolor> attribute with the <marquee> tag.
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title> Example of Background color Attribute </title> </head> <body bgcolor="lightgreen"> <!-- The attribute bgcolor use with the body tag to set the background of web page as lightgreen --> <h1> <font color="blue"> <marquee bgcolor="orange"> <!-- The attribute bgcolor use with the marquee tag to set the background of marquee as orange --> javaTpoint </marquee> </font> </h1> </body> </html> Test it NowOutput:
Browser Support
Element | Chrome | IE | Firefox | Opera | Safari |
<bgcolor> | Yes | Yes | Yes | Yes | Yes |
Từ khóa » Html Color Tag Background
-
How To Add & Change Background Color In HTML - HubSpot Blog
-
HTML Colors - W3Schools
-
HTML Styles - W3Schools
-
How To Set Background Color In HTML? - Tutorialspoint
-
Change HTML Background Color Or Font Color - BitDegree
-
HTML Background Color - HTML Color Codes
-
How To Change Background Color In HTML? - Top 5 Methods That ...
-
HTML | Bgcolor Attribute - GeeksforGeeks
-
HTML Color Codes And Names - Computer Hope
-
Background-color - CSS: Cascading Style Sheets - MDN Web Docs
-
HTML Background Color - Set And Change - STechies
-
How To Set Background Color With HTML And CSS - W3docs
-
#FFFFFF (White) HTML Color Code - Computer Hope