CSS, How to use Shorthand Properties!

Shorthand Properties allow the values of several properties to be specified within a single property. Shorthand properties are easier to write and maintain. They also make CSS file smaller and faster to load.

For example, the h2 element can be styled with font-style, font variant, font-weight, font-size, line-height, and font-family or with a single font property. see below:

Traditional:

h2 {

font-style: italic;
font-variant: small-caps;
font-weight: bold;
font-size: 100%;
line-height: 120%;
font-family: arial, helvetica, sans-serif;

}

Shorthand:

h2 {

font: italic small-caps bold 100%/120% arial, helvetica, sans-serif;

}

Most shorthand properties do not require the values to be placed in a set order. However, when using the font property, it is safer to set values in the order specified by the W3C, which is font-style, font-variant, font-weight, font-size, line-height, and font family.

When font-size and line-height are used within the font property, they must be specified with font-size first, followed by a forward slash(/), followed by line-height.

Values for the short hand font property include font-style, font-variant, font-weight, font-size, line-height, and font-family. However,  all of these values do not need to be included in a shorthand declaration. Foe example, for the  <p> element, you might want to only specify values for font-size and font-family

p {

font: 80% arial, helvetica, sans-serif

}

In this case , font-style, font-variant, font-weight, and line-height are not included in the shorthand property, so they will be assigned their default values.

Helpful Articles

Trying to Lose Weight, Go Out With Friend And Family And Not Offend

This may sound amazing, but one of the hardest things to do when you are losing weight is to get the help of friends and family...

Top 10 Weight Loss Myths

Have you sometimes felt confused about weight loss and nutrition guides that should help you take the right decisions about your health, yet for some reason they don’t? Here are some of the most frequent weight loss theories, and their rebuttals...

How Do I Get Out Of A Weight Loss Plateau, Problem And Solution No. 2

When you ask the question “how do I get our of a weight loss plateau?” there can be more than one answer, depending on what the reason for the problem is...

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • BlinkList
  • blogmarks
  • email
  • Fark
  • LinkaGoGo
  • LinkedIn
  • Live
  • MySpace
  • StumbleUpon
  • Technorati
  • Twitter
  • Propeller
  • Yahoo! Buzz

Tags: , , , , , ,

Leave a Reply