Style Sheets
  Home arrow Style Sheets arrow Page 4 - CSS Shorthand at a Glance
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  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
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 Shorthand at a Glance
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 17
    2005-02-08

    Table of Contents:
  • CSS Shorthand at a Glance
  • Basic CSS rules
  • Font shorthand property
  • Background shorthand property
  • Margin shorthand property
  • Padding shorthand property
  • Border shorthand property
  • List-style shorthand property

  • 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

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    CSS Shorthand at a Glance - Background shorthand property


    (Page 4 of 8 )

    In order to implement the "background" shorthand property, the syntax is:

    background: background-color | background-image | background-repeat | background-attachment | background-position;

    As its name suggests, the "background-color" property sets the background color of the selected element. It may be set to any HTML color code or name, or transparent.

    The  "background-image" property sets the background image for the selected element. It may be set to a URL or "none."

    Possible values for the "background-repeat" property are: "repeat-x" (background image is tiled horizontally), "repeat-y" (background image is tiled vertically), "repeat " (both ways), and "no-repeat" (not tiled at all).

    Regarding the "background-attachment” property, it sets whether the background image of the selected element scrolls with it or remains fixed while the element’s contents scroll over it. This property can be set to "fixed" or "scroll."

    Finally, the values for "background-position" allow us to specify the position of the top-left corner of the background image. We can specify one or two percentages, lengths or positions, where the first specifies the horizontal position and the second specifies the vertical position. If the vertical position is not specified, it’s taken to be 50%.

    Once again, let’s code a couple of examples:

    background: #00f url("bg.gif") repeat-x center left;

    background: #fff url("bg.gif") no-repeat fixed center center;

    Here we’ve specified a blue background, and a background image that will be tiled horizontally (across the X axis), horizontally positioned at the center and vertically positioned at the left of the element.

    In the second example, we’ve assigned a white background, using a background image that won’t be tiled at all. The background image will be horizontally and vertically positioned at the center of the element. The "fixed" property indicates that the image will remain fixed as the element’s contents scroll over it.

    Now, it’s time to have a look at the next CSS shorthand property.

    More Style Sheets Articles
    More By Alejandro Gervasio


       ·  Here's a tight reference about the most common CSS shorthand properties,...
       · I always thought this stuff was common sense...Guess I took it for granted... I...
       ·  I agree with you about writing clean CSS code. That's the right way to...
     

    STYLE SHEETS ARTICLES

    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - 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







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