CSS for Beginners

CSS for Beginners

CSS is the language we use to style an HTML document.

Style sheets

image.png

Make a new file called styles.css and save it to the same folder as the HTML file. Enter the code as above into your HTML file. This will link the HTML file to the CSS file.

Selectors

image.png

Selectors are used to select the element(s) you want to style. In the picture above we are targeting the p element and changing the colour to tomato and the size to 200 px. Results below.

image.png

image.png

In the picture above we are targeting two elements. p and h1

Ids and classes

Class attribute is used to specify a class for an HTML element. Multiple HTML elements can share the same class.

id attribute is used to specify a unique id for an HTML element. You cannot have more than one element with the same id in an HTML document.

image.png

image.png

image.png

Common Properties

developer.mozilla.org/en-US/docs/Web/CSS/CS..

All Properties

w3schools.com/cssref

DIV

image.png

image.png

image.png

Div tag defines a division or a section in an HTML document. The div tag is styled by using the class or id attribute.