Forum : <body style="background-color:yellow"> Vs <body bgcolor="yellow">
Brief description  about Online courses   join in Online courses
View Rajat  Saddi 's Profile

<body style="background-color:yellow"> Vs <body bgcolor="yellow">

Both the tags generate the same result. So which one to choose and why?
Asked by Rajat Saddi | Sep 9, 2009 |  Reply now
Replies (3)
View douglas g wolfe 's Profile
The reason it was considered the wrong answer is the wording of the question. The question asked which was the right HTML code not which would set the bgcolor. The answer you gave is the inline css style tag and the other is the html tag. Both will do the same thing, but one uses only html to do it, th other uses a css tag inline and that is the difference.
Dec 16, 2009
View rajat saddi 's Profile
Thanks..
These choices were there in one of the HTML question. So, according me both the options are correct to set background colour for a body. But <body style="background-color:yellow"> was considered wrong by the evaluator. Don't know why?
Sep 9, 2009
View sanjay s nair 's Profile
<body bgcolor=\"yellow\">
this uses bgcolor property of the body tag

<body style=\"background-color:yellow\">
uses the css to display background color.

Suppose you are working on a big project with some 100 pages in it. For such projects we write external css files and link it with every 100pages. You might know about what an external stylesheet is and how to link it in a page, if you have completed the CSS section of the tutorial. Now we only need to change one css file to change the background color of body, and it will affect every 100 pages.

So i think the first one with css is the better way.

Regards,

Sanjay S Nair
Sep 9, 2009