5
CSS – Week 1 C. Collins

CSS - Week 1

Embed Size (px)

Citation preview

Page 1: CSS - Week 1

CSS – Week 1C. Collins

Page 2: CSS - Week 1

Introduction to CSS

CSS (which stands for Cascading StyleSheets) is a language used to put a style on a html webpage.

Why use a CSS file?

In the past we styled a webpage inside the HTML document.

From now on we will be styling it in a different document.

(When saving a CSS file it needs to be saved as .css)

1.You can apply the same formatting to several HTML elements without rewriting code (e.g.style="color:red":) over and over2.You can apply similar appearance and formatting to several HTML pages from a single CSS file

Page 3: CSS - Week 1

Linking your CSS and HTML documents

To link a css page to a HTML page we put a <link> tag in our head.

Inside this tag we must add three things.

This is what it should look like:

<link type="text/css" rel="stylesheet" href="stylesheet.css"/>

1.A type attribute that should always be equal to "text/css"2.A rel attribute that should always be equal to "stylesheet"3.A href attribute that should point to the name of your CSS file

Page 4: CSS - Week 1

How to write CSS

This is what any part of your CSS file should look like:

P{

Color: red;

}

On the first line you have the thing you want to style (e.g a paragraph). Then you have an opening curly bracket ({).

On the next line you have the style you want to change (e.g the color). Then you have a colon (:). Then you have what you want to change it to (e.g red). Then put a semi-colon (;)

On the next line you have a closing curly bracket (}).

Page 5: CSS - Week 1

Comments

This is what a comment looks like in CSS:

/*I'm a comment!*/