avazwij avazwij - 2 months ago 8
CSS Question

what's difference between writing element properties in CSS or directly?

Displaying a DIV using CSS:

div.divBg {
background-color : red;
width : 200px;
height : 300px;
}


This displays what is set in CSS:

<div class = "divBg">
</div>


writing the same settings inside the DIV itself does not work:

<div background-color ="red" width = "200px" height = "300px">
</div>


please tell me what i am missing

Answer

change

<div background-color ="red" width = "200px" height = "200px">

to

<div style="background-color:red; width:200px;height:200px">