www.webdeveloper.com
Results 1 to 3 of 3

Thread: Why use CSS for background when . .

  1. #1
    Join Date
    Apr 2003
    Posts
    1

    Why use CSS for background when . .

    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.

  2. #2
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    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.

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,277
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles