130 likes | 315 Vues
CSS. The basics { }. CSS. Cascading Style Sheets - language used to describe html appearance & formatting Style Sheet - file that describes how html file should look Cascading - sheets can apply formatting to: all elements on a page
E N D
CSS The basics { }
CSS • Cascading Style Sheets - language used to • describe html appearance & formatting • Style Sheet - file that describes • how html file should look • Cascading - sheets can apply formatting to: • all elements on a page • can single out a specific - i.e. paragraph- to have a different style
What’s the Difference? • CSS can apply same formatting to • several HTML elements • without rewriting each line of code (e.g. style="color:red":) again and again • CSS can apply appearance/ formatting to • several HTML pages • from a single CSS file
Where is CSS placed in html doc? • Between<style> here </style> tags inside html file • <style> tags go inside<head> </head> of a webpage • Example • <!DOCTYPE html><html><head><style> p { color: purple; }</style><title>Result</title></head><body><p>Purple text </p></body></html>
Selector -any html element (i.e. <p>, <img>, or <table>, but remove the <>s) • Property - an aspect of a selector (i.e. to change the font-family, color, and font-size of the text on a web page) • Value - a possible setting for a property (i.e. color can be red, blue, black, or almost any color; font-family can be any number of different fonts, etc.)
CSS Example: make a paragraph's text red with CSS: selector{property: value;} ____________________ p{color: red;}
Set multiple properties Example p {font-family: Garamond;color: green;font-size: 24px;}
Single Properties in multiple tags Example:Heading color red; paragraphs in Courier; span background in yellow h3 {color: red;}p {font-family: Courier;}span { background-color: yellow;}
Link html file to CSS file • so html file can see/use the CSS file • The link file placed between <head> </head> <link> tag needs 3 attributes:1st attribute - type="text/css"2nd attribute - rel="stylesheet”3rd attribute - href="web address of CSS file"/>Example<head> <link type="text/css" rel="stylesheet" href="stylesheet.css"/> <title>blah</title></head>