HTML <hr> color Attribute Last Updated : 28 Jun, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The HTML <hr> color attribute was traditionally used to set the color of horizontal lines for visual separation in content. Although this attribute is deprecated in HTML5, similar and more flexible effects can now be achieved using CSS. By styling the <hr> element with properties likeborder,background-color and even using opacity (e.g., opacity: 50% .You can control both the color and transparency to match modern design needs.Note: It is not supported by HTML5.Syntax:<Hr color= "color_name | hex_number | rgb_number"> Attribute Values: Attribute ValuesDescriptioncolor_nameIt sets the Text color by using the color name. For example, “red”.hex_numberIt sets the text color by using the color hex code. For example, “#0000ff”.rgb_numberIt sets the text color by using the RGB code. For example: “RGB(0, 153, 0)”.Example: In this example demonstrates the deprecated <hr> color attribute to set colors for horizontal lines. The lines are styled with attributes like color, size, and width, although modern styling should use CSS instead. html <!DOCTYPE html> <html> <head> <title> HTML hr color Attribute </title> </head> <body style="text-align:center;"> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> Hr color attribute </h2> <hr width="500px;" color="red" size="10"> <p>Computer science portal</p> <hr width="70%" size="20" color="blue" noshade> </body> </html> Output: Example 2: In this example CSS to style <hr> elements with a custom color and width, aligning them centrally. It showcases modern methods for styling horizontal lines without using the deprecated <hr> color attribute. index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>GeeksforGeeks</title> <style> body { text-align: center; font-family: 'Arial', sans-serif; background-color: #f4f4f4; color: #424242; margin: 0; padding: 20px; } h2 { margin-bottom: 20px; } hr { border: 2px solid #e74c3c; width: 50%; margin: 20px auto; } </style> </head> <body> <h1 style="color: #4CAF50;"> GeeksforGeeks </h1> <h2>HR Color Attribute Example</h2> <hr> <p style="color: #555;"> Your go-to computer science portal for knowledge and insights </p> <hr> </body> </html> Output:Browser Support Attribute<hr>✓✓✓✓✓Desktopv1v12v1v1v15Mobilev18–v4v1v14 Comment More infoAdvertise with us Next Article HTML bgcolor Attribute M manaschhabra2 Follow Improve Article Tags : HTML HTML-Attributes HTML-Basics Similar Reads HTML <td> bgcolor Attribute The HTML <td> bgcolor attribute is used to specify the background color of a table cell. It basically, Specify the background color with a hexadecimal code for precise coloring and offers limited color choices compared to modern CSS styling. Note: It is not supported by HTML5. Syntax:<td b 2 min read HTML <th> bgcolor Attribute The bgcolor attribute in the HTML <th> (table header) tag is used to set the background color of a table header cell. You can specify colors using color names, hexadecimal codes, or RGB values. Note: It is not supported by HTML5. Syntax:<th bgcolor="color_name | hex_number | rgb_number"> 2 min read HTML <tr> bgcolor Attribute The HTML <tr> bgcolor Attribute is used to specify the background color of a table row. This attribute accepts color values such as color names, hex codes, or RGB values, allowing for easy customization of the background color for individual rows in an HTML table.Note: It is not supported by H 2 min read HTML <col> bgcolor Attribute The HTML <col> element bgcolor attribute was used in HTML to set background colors for table columns. It is deprecated in HTML 4.01 and not supported in HTML5. Instead, CSS should be used to style table columns with the background-color property. Syntax: <col bgcolor= "color_name | hex_numb 2 min read HTML <body> bgcolor Attribute The bgcolor attribute in HTML was traditionally used to set background colors for elements such as <body>, <table>, <td>, and <tr>. It supports named colors, hex codes, and RGB values. However, since it's deprecated in HTML5, over 90% of modern developers now prefer using CSS 2 min read HTML <table> bgcolor Attribute The bgcolor attribute in HTML <table> tag was previously used to set the background color of a table. It was once generally used in over 60% of legacy websites to quickly style table elements without depending on CSS. Although modern best practices recommend using CSS for styling, understandin 1 min read Like We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy Got It ! Improvement Suggest changes Suggest Changes Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal. Create Improvement Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all. Suggest Changes min 4 words, max Words Limit:1000 Thank You! Your suggestions are valuable to us. What kind of Experience do you want to share? Interview Experiences Admission Experiences Career Journeys Work Experiences Campus Experiences Competitive Exam Experiences