How To Replace Td Bgcolor With CSS Background Property » - HTML
Có thể bạn quan tâm
Code Example
<table> <tr> <td>This cell has no bgcolor attribute.</td> <td bgcolor="blue">This cell has a bgcolor attribute.</td> </tr> </table>| This cell has no bgcolor attribute. | This cell has a bgcolor attribute. |
Don’t Use bgcolor
Before CSS enjoyed broad browser support, many attributes sprang up that allowed web developers to style HTML tables by adding styling directly to each HTML element. Today, we no longer use HTLM to style websites so all of these attributes, including bgcolor have been deprecated. Don’t use them. Instead, use the CSS background property.
How bgcolor Worked
The bgcolor would accept a generic color name, a hex color code, or an RGB color code and apply that color to just the specific <td> element. In modern web design, the same effect can be accomplished by using CSS.
<style> .blue { background: blue; } </style> <table> <tr> <td class="blue">This cell is styled with CSS.</td> <td bgcolor="blue">This cell has a bgcolor attribute.</td> </tr> </table>Most browsers still support the bgcolor attribute. So you should see both cells styled in the same fashion below. However, browsers may drop support for bgcolor at any time. To ensure that all of your site’s users have the best experience possible, stick to CSS and avoid this deprecated attribute.
.blue{background: blue;}| This cell is styled with CSS. | This cell has a bgcolor attribute. |
Post navigation
What Does Td Colspan Have To Do With Tables In HTML?AppletsSearch HTML.com
Search for:Most Popular
- <var> HTML Tag306 views
- What Is Doxing? (And Why Is It So Scary?): An Infographic85 views
- New Audio HTML Element: Master It Out Now With Our Code Example62 views
- The Web Worker's Stress Busting Toolbox: 50 Tips to Improve Your Life43 views
- <meter> HTML Tag41 views
Từ khóa » Html Table Bgcolor Not Working
-
Why Is My Table Background Color Not Working In Htm5?
-
Why Table Bgcolor Is No Longer Valid Code (And What To ... - HTML
-
How To Change The Background Color Of An HTML Table - ThoughtCo
-
HTML |