Style Sheets
  Home arrow Style Sheets arrow CSS: Backgrounds
Iron Speed
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

CSS: Backgrounds
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-03-03

    Table of Contents:
  • CSS: Backgrounds
  • How to Set the Background Color
  • Working with Background Images
  • Positioning the Background Image
  • Text in CSS

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    CSS: Backgrounds
    (Page 1 of 5 )

    In the last tutorial we discussed the basics and syntax of CSS, where to write the files and how to apply them to our pages. In this brilliant article, we will go over how to apply styles to backgrounds and text. So let's get busy.

    To apply a style to a background, we use one of the various background properties. You can use the background property not only with the page, but other elements as well, such as text and tables. Speaking of tables, here is a nifty one showing you a list of available background properties:


    Name of Property

    What it Does

    Associated Values

    background

    Sets all background properties in a single declarative statement

    background-color

    background-image

    background-repeat

    background-attachment

    background-position

    background-attachment

    Allows you to determine if a background image scrolls with the page or is fixed

    scroll

    fixed

    background-color

    Allows you to set the background color of a given element

    color-rgb

    color-hex

    color-name

    transparent

    background-image

    Allows you to set an image for your background

    url


    background position

    Allows you to set the starting position of your background image

    top left

    top center

    top right

    center left

    center center

    center right

    bottom left

    bottom center

    bottom right

    x% y%

    xpos ypos

    background-repeat

    Allows you to set whether or not a background image will repeat, and if so, how it will do so

    repeat

    no-repeat

    repeat-x

    repeat-y

    Setting Every Background Property with the Background Shortcut

    In this example we will use the background property to set all of the background attributes of the body and paragraphs:


    <html>

    <head>

    <style type="text/css">

    body

    {

    background: black url('welcom.gif') no-repeat fixed center;

    }

    p

    {

    background: green left}

    }


    </style>

    </head>


    <body>

    <p>The matrix has you</p>

    </body>


    </html>

    This is the result of the above code:




    Every paragraph you type will have the same attributes as the first.

    More Style Sheets Articles
    More By James Payne


       · Thanks for stopping by to read my article on CSS Backgrounds. Here we discuss such...
     

    STYLE SHEETS ARTICLES

    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification
    - CSS: Dimensions
    - CSS: Margins and Padding
    - CSS: Crossing the Border
    - CSS: Text, Fonts, and Tables
    - CSS: Working with Text
    - CSS: Backgrounds
    - CSS for the Newbie
    - Styling Web Page Headers with Transparent Ba...
    - Creating Angled Corners with Transparent Bac...
    - Style Sheets for a Useful Links Page
    - Modifying the Look and Feel of Individual El...
    - Using Persistent Styles with Multiple Style ...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway