You are currently browsing the page Shortcuts in the CSS category.

Shortcuts

Grouping

If you have the same style for two or more selectors, you can group them!

p, h1, h2 {
font: 12px Arial, sans-serif;
}

Shorthand properties

I always use shorthand properties to have a lighter stylesheet. For example, if you have background properties set like this:

body {
background-color: #FFF;
background-image: url(image.jpg);
background-repeat: no-repeat;
}

The code can be shortened to one line:

body {
background: #FFF url(image.jpg) no-repeat;
}

Print This Post Print This Post



Sponsors


One Response to “Shortcuts”

To add to this list here's the shortcut for font :-

font:normal 12px verdana;

this will set the font-weight:normal; font-size:12px; font-family:verdana;


Leave a Comment

Works? Doesn't work? Other tips? Please leave a comment! :)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

To post codes, please go to SimpleCode and transform your codes first, so that it will displayed properly. Indeed, < and > need to be converted to &lt; and &gt; :)


Close
E-mail It