Style Sheets
  Home arrow Style Sheets arrow Page 5 - 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  
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 Shorthand at a Glance
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 20
    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


    CSS Shorthand at a Glance - Margin shorthand property


    (Page 5 of 8 )

    The syntax for the "margin" shorthand property is the following:

    margin: margin-top | margin-right | margin-bottom | margin-left;

    Margin properties set the size of the margin between the outside of an element’s border and surrounding page elements. Let’s list some examples for proper understanding:

    h2 {

         margin: 5px;

    }

    h2 {

         margin: 5px 20px;

    }

    h2 {

         margin: 1em 2em 4em;

    }

    h2 {

         margin: 5px 20px 5px 20px;

    }

    In the first example, all of the margins for the <h2> element are set to 5px. In the case where only one value is specified, it will be applied to all sides of the element. In the second example, where only two values have been specified, CSS interprets the first as being the value for the horizontal margins, that is, those at the top and bottom of the element. The second value defines the right and left margin sizes for the element.

    In the third example, where three values have been defined, the first value is set to "margin-top," the second is set to "margin-right" and the third is set to "margin-bottom," respectively.

    When four margin values are defined for the element, they’re automatically applied to the borders, moving around the element in a clockwise direction, that is top, right, bottom and left, respectively.

    Let’s see another interesting shorthand property, which consists of using padding.

    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...
       · The correct explanation for three shorthand values is:"If there are three...
       · Yes, that's correct. Thanks for pointing out that small error.
     

    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