I am new to CSS and am probably missing something regarding this question so I hope it is not too dumb of a question: I am wondering why use CSS code for setting back ground when simple html will set it as in the examples below?
WHY USE THIS CSS CODE:
<style type="text/css">
body
{
background-image:
url("bgdesert.jpeg")
}
</style>
</head>
WHEN THIS WILL DO:
<body background="bgdesert.jpeg">
</body>
Thanks! Any help is appreciated.HTML is meant to describe the structure of a document and was never designed to describe visual rendering. So CSS was put together to give the author much more control over the visuals of the site, makes pages much more accessible by removing HTML tags and attributes that were never planned to be there, and external style sheets allows the author to make a site wide change in a single place.
The background attribute does still work. However, it is still far better (for the reasons listed above) to use style sheets instead. And the now deprecated parts of HTML will probably one day be removed from browsers, though it is probably still a long ways off since it is still being used on some pages.Also, if you put your CSS in a separate file then you will save a modicum of bandwith and make happy your users with slow connections. If you use all the same style sheet for each page on your site then browsers will only need to download the file once and non-visual and text-only browsers will not have to download the file at all.
WHY USE THIS CSS CODE:
<style type="text/css">
body
{
background-image:
url("bgdesert.jpeg")
}
</style>
</head>
WHEN THIS WILL DO:
<body background="bgdesert.jpeg">
</body>
Thanks! Any help is appreciated.HTML is meant to describe the structure of a document and was never designed to describe visual rendering. So CSS was put together to give the author much more control over the visuals of the site, makes pages much more accessible by removing HTML tags and attributes that were never planned to be there, and external style sheets allows the author to make a site wide change in a single place.
The background attribute does still work. However, it is still far better (for the reasons listed above) to use style sheets instead. And the now deprecated parts of HTML will probably one day be removed from browsers, though it is probably still a long ways off since it is still being used on some pages.Also, if you put your CSS in a separate file then you will save a modicum of bandwith and make happy your users with slow connections. If you use all the same style sheet for each page on your site then browsers will only need to download the file once and non-visual and text-only browsers will not have to download the file at all.