N5 – CSS Selectors

CSS is used to change the look of the website but not the HTML content of the website.

At National 5 there are 3 CSS selectors. These are used to identify which parts of the web page are styled by CSS instructions.

  • Element selector – This is used to select all html elements of the given type.

P {color:red;}

P is the element selector

Color is the CSS property

Red is the CSS value

  • Class selector – this is used to target HTML elements of a given class.

.center {text-align:center;}

.center is the name of the class selector

Text-align is the CSS Property

Center is the CSS Value

  • ID Selector – this is used to target a unique HTML element on the page. NB Only one ID with the same name on a page.

#pageHeading {color:white;}

#pageHeading is the ID selector

Color is the CSS property

White is the CSS value

Leave a Reply

Your email address will not be published. Required fields are marked *