The Best Web Design Tips Blog



Linking to an external stylesheet, and how to write clean CSS?


One of the beauties of CSS is the external stylesheet that helps in controlling the style presentation of a large set of web pages. You can very well change the font size of an entire website by tweaking a single external stylesheet! Here is how you kick off with it:

Firstly create an external stylesheet file including all the various styles you may require for your website. The content of the stylesheet is the same as those of the <style> section in your web pages. Save it in the 'style' folder (considering that you have a 'style' folder consisting of various styles individually). Name it with a .css extension, like example.css.

Attach this one line of code to the 'head' section of every web page of your website in this manner:


The Code


<link type=“text/css” rel=“stylesheet” href=“example.css”>

With this you are done. go ahead play around with your web pages. Yippee! You've got the master key to CSS now!

Writing a clean CSS code may seem tedious initially but the after-advantages of these overshadow the initial bothers. Here are few tips:

Writing Clean CSS

  1. Double space between 'styles'.
  2. Indent every declaration block with one or two tabs. (It makes for a clearer reading!).
  3. Break the codes into organized sections like - General overview, global styles, header, navigation, major content, various classes and styles and footer.
  4. Don't forget to write relevant comments.

Link to This Page: