Style Sheets
  Home arrow Style Sheets arrow Page 7 - CSS Shorthand at a Glance
IBM developerWorks
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 
VeriSign Whitepapers 
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
     
    Iron Speed
     
    ADVERTISEMENT

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    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...
     

    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


    Iron Speed





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