» Smart Phones, Web Design, Google or whatever
CSS Shorthand
Looking around for my last CSS post about cross-browser transparency I ran into a post about 5 Cool CSS Tricks on BrightCherry.co.uk by a dude named Maruf which reminded me of some other cool CSS that I find useful. Here is one of those – CSS Shorthands.
CSS Shorthand
CSS can get quicker and easier to use if you know some of the shorthand properties (more CSS shorthand properties). For example you could code a background image and its placement like this:
CSS Shorthand for Background
.backgrnd {
background-image: url(images/background.jpg);
background-position: top center;
background-repeat: no-repeat;
}
You could do it that way or you could use shorthand:
.backgrnd {
background: url(images/background.jpg) top center no-repeat;
}
CSS Shorthand for Font
.maxedoutfont {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 14px;
font-weight: bold;
font-style: italic;
font-variant: small-caps;
}
You could do it that way or you could use shorthand:
.maxedoutfont {
font: Arial, Helvetica, sans-serif 12px/14px bold italic small-caps;
}
Note that, as Maruf mentioned in his post, you must specify at least the font-family and font-size. If you do not specify line-height, font-weight, font-style or font-variant then normal (the CSS defaults) will be used/inherited.
| Print article | This entry was posted by George on July 31, 2009 at 9:14 pm, and is filed under Web Design. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
ABOUT COMMENTING ON THIS BLOG
Comments are moderated by a human and will be approved if they bring value to the discussion. This means comments are on topic, relevant and useful. Here are some ways to insure your comment is rejected, marked as spam or will be edited (at my discretion):
- Using keywords, business names or website names in the Name field
- Putting a spammy site/page in the Website field
- Foul, abusive or discriminatory language
- Comments for SEO only purposes