Style Sheets
  Home arrow Style Sheets arrow Page 3 - CSS: Backgrounds
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  
Mobile Linux 
App Generation ROI 
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
     
     
    ADVERTISEMENT


    CSS: Backgrounds - Working with Background Images


    (Page 3 of 5 )

    There are a lot of issues to consider when you work with images, such as image size, position, does it scroll or stay in one spot, and so forth. But first let's insert a basic image in a paragraph:

    <html>

    <head>

    <style type="text/css">

    body

    {

    background-image:

    url('2.png')

    }

    </style>

    </head>

    <body>

    </body>

    </html>

    This will take the file 2.png and set it as the background of your body. If your image is the wrong size, you will notice that your browser tiles the image over and over again. To stop this, you can use the background-repeat property.

    Repeating and Not Repeating the Background

    To make sure the background does not tile, use the background-repeat:no-repeat property, like so:


    <html>

    <head>

    <style type="text/css">

    body

    {

    background-image:

    url('2.png'); background-repeat:no-repeat

    }

    </style>

    </head>

    <body>

    </body>

    </html>

    Or if you wanted it to repeat, you could do this:


    <html>

    <head>

    <style type="text/css">

    body

    {

    background-image:

    url('2.png'); background-repeat:repeat

    }

    </style>

    </head>

    <body>

    </body>

    </html>

    You can also make the background repeat horizontally or vertically using either the repeat-x (horizontal) or the repeat-y (vertical) values.

    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

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek