CSS for Styling Text
Again….CSS Cascading Style Sheet Write rules to apply styles to page content What can you style? Imagine the Possibilities: CSS Zen Garden Show students the CSS Zen Garden site. This site makes available an html page and a style sheet that graphic designers can use to submit their own styling of the page. As you select a design, ask students to notice how the content (text) of the page isn’t changing. Not changes are being made to the html file, only changes to the CSS used to apply styles to it. Have students note the extreme differences in style applications that have been provided as examples to this site.
Creating a CSS Rule Selector: what element to style? Property: what portion of element tweak? Value: sets value for that property
Selector Selector can be any html tag If selector is a tag, will apply style to all such tags on the page
Internal Style Sheet Define your styles in the actual html page Only applies to that page (this is just 1 of 3 options – see others later)
Where does the CSS go? <head> section After the meta tags Between two <style> tags Define as many style rules there as you need
How to set the values of certain properties
CSS Comments let you make notes to yourself about design Color of the Text Property: color Value: Hex-color code, or one of the color constants (words for colors) that Brackets offers Example: Hex code CSS Comments let you make notes to yourself about design Color constant
Color Behind Text Property: background-color Value: Hex-color code, or one of the color constants (words for colors) that Brackets offers Example:
Size of the Text Property: font-size Value: number value in pixels (there are other units we’ll see later) Example:
Font Weight Property: font-weight Value: Example: Number value: 100 (lightest) – 900 (boldest) bold | bolder | lighter | normal Example:
Font Choice Property: font-family Value: Example: Generalized kind of font: cursive, fantasy, monospace, sans-serif, serif Specific font, like arial, times new roman, etc. Example: If font name is more than one word, surround it with quotes If a font is not installed on the user’s computer, then it can’t be displayed, and the browser will try to compensate To deal with this, good idea to provide a list of fallback fonts – it will try each one you list from left to right and keep trying if a font is not available Can mix specific fonts and generalized kinds of fonts Good idea to make generalized kind of font the last option on the list and the browser will find a comparable font on the user’s computer to use List can be as many fallback fonts as you want
Line Height Property: line-height Value: number in pixels (other units possible we’ll see later) Example:
Alignment of Text Property: text-align Value: center | justify | left | right Example: