Style Sheets
  Home arrow Style Sheets arrow Page 7 - 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 - Border shorthand property


    (Page 7 of 8 )

    The syntax for this shorthand property is the following:

    border: border-width | border-style | border-color;

    Border-width refers to the width of the border surrounding the selected element, while "border-style" specifies the style applied to that border. Possible values for this property include: "double," "groove," "inset," "ridge," "solid," "dashed," "dotted," and "none."  Finally, the "border-color" property sets the color for the border of the element.

    In order to understand these properties, two examples are listed below:

    p {

         border: 1px solid blue;

    }

    p {

         border: dotted blue;

    }

    The first case will display a solid blue line of 1px for each border of a <p> element. The second example will show a dotted blue line for all the borders of the <p> element.

    Still with me? Excellent. Let’s focus on another useful CSS shorthand property: individual borders.

    Border-top, border-right, border-bottom and border-left shorthand property

    The syntax for this shorthand property is:

    border-top: border-width | border-style | color;

    border-right: border-width | border-style | color;

    border-bottom: border-width | border-style | color;

    border-left: border-width | border-style | color;

    These properties work identically to those defined for "border." However, the "border" property itself is not capable of discerning between the four sides of an element. These are specifically aimed to let you set a style to a specific border.

    Take a look at the following examples:

    p {

         border-top: 1px solid red;

    }

    p {

         border-right: solid blue;

    }

    p {

         border-bottom: 1px dotted red;

    }

    p {

         border-left: 2px solid #ffc;

    }

    The first case will display a solid red line of 1px for the "border-top" of the <p> element.

    The second case will show a solid blue line for the "border-right" of the element.

    The third and fourth examples will display a <p> element with a red dotted line of 1px for the "border-bottom," and a 2px yellow solid line for the "border-left" of the paragraph, respectively.

    For the next section, we’ll see another handy shorthand property: list-style.

    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

    - 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...
    - Pulling Web Page Elements with the Blueprint...
    - Pushing Web Page Columns with the Blueprint ...
    - Controlling Column Padding with the Blueprin...
    - Prepending Classes in the Blueprint CSS Fram...
    - Appending Grid Units with the Blueprint CSS ...
    - Changing Grid Units in the Blueprint CSS Fra...
    - The Blueprint CSS Framework
    - Building a Liquid Design with Evened Margins...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT