Gaurav Aggarwal Gaurav Aggarwal - 7 months ago 13
HTML Question

What should use bgcolor or background-color?

I tried to find it everywhere but not able to find a perfect explanation about it.

At some codes we see

bgcolor
to set background color like this

bgcolor="#FFFFFF"


and some uses
background-color
or
background
like this

element{
background-color:#fff
}


I know that
bgcolor
is a html attribute and
background-color
is css but which is best to use and is there any difference?

Answer

The bgcolor attribute was superseded by CSS in 1996.

CSS background properties:

  • Are more reusable
  • Have a higher priority than presentational attributes
  • Take a wider selection of values (including translucent ones)
  • Can be stored in an external stylesheet and cached between requests
  • Apply more consistently across different element types
Comments