Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register

Go Back   WebForumz.com > Resources > Tips & Tricks > (X)HTML & CSS
Register All Albums Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read

Author


Jack Franklin
Jack is 15 years old and lives happily in Cornwall, England. Web Design is his passion and he works using xHTML, CSS and PHP to code his websites, with the odd bit of Javascript now and then. In his spare time, Jack enjoys playing Football, rugby, tennis and snooker (but not all at the same time).

RSS Feed

Your Options
Use Shorthand CSS to lighten file load time.

Lower File Size=Lower load time. Learn how to streamline your CSS to decrease the loading time.

Currently you might be styling margins like so:

margin-top: 50px;
margin-right: 10px;
margin-left: 15px;
margin-bottom: 20px;


But there is an easier way. You can combine all those styles together into one declaration:

margin: 50px 10px 20px 15px;

That will assign all your margins. The order is: margin: Top Right Bottom Left;

Incase you have trouble, coder Alex Perry came up with this handy way of remembering!
The
Rhino
Broke
Loose

Or you can assign just two values:

margin: 50px 20px;

This will asign the Top and Bottom margins 50px, and the Left and Right margins 20px. Another useful shorthand is the background declaration. Instead of this:

background-color: #0099CC;
background-image: url'(path/to/your/image.jpg');
background-position: top left;
background-repeat: none;

You can place it, like we did with the margins, into just one declaration:

background: #0099CC url('path/to/your/image.jpg') no-repeat top left;

This shorthand can be done with any style that has sub-values. Two of the best examples include fonts:

font: italic bold 12px Arial;

And borders:

border: 2px solid #0099CC;

Using shorthand can be very helpful to you. It means your CSS stylesheet is not as long, so less scrolling and searching for certain properties. It also can help to decrease the file size of the CSS sheet. This therefore means it takes less time to load, which can only be beneficial to your website.


Related Resources

Members's Comments No Comments. Be the first to comment on and rate this resource.


Search Engine Optimization by vBSEO 3.2.0 RC8