Google search
Language: In english please! På svenska tack!
By Anne, 2006-08-10

Using simple css on your site

Making a .css -file for the first time

You need to open a text-editor for this one. All css-files have the file-extension .css, so lets save this file as for example: mystyle.css! Now with the empty css-file opened up in a texteditor we can start filling in some simple directions for how we like our webpage to look like. But, for the browser to read and implement the style on your webpages, we need to insert a simple line of code in the head section of the html-page/pages that are going to use this css-stylesheet. Below, an example of my index.html:

Ok, so now we go back to the "mystyle.css"-file and add a few attributes for our webpage style. This is how it will look like for starters in mystyle.css:

Let's break this code apart, so you'll understand it better! The body at the beginning means that the body-tag in your html-document will have the following style, contained between the "{}"-tags. Then the actual style comes as you can see. Margin, padding, background-color.... and so on. Every statement has to end with a semicolon; before you can start the next. It's really simple stuff. Remember that if you misspell, the code will not work.

When you're done with the basic body-style, you might want to move on and add some styles to other html-tags like links for example: