Beyond the Basics: Stylesheets
CSS Basics
- Style: collects all the properties to be applied to a section of similar text (headers, titles, paragraphs, etc.)
- CSS: Put CSS in a central location -- can affect appearance of HTML tags on an individual web page OR across an entire web site.
SYNTAX of STYLES
Basic Syntax:
someTag { propertyName : propertyValue;
propertyName : propertyValue
}H1 {font-size: 15pt;
font-weight: bold;
}
Placement of CSS Rules to Declare Styles:
|
Affect ONE occurrence |
<H5 STYLE="background-color:blue; |
| Change appearance of an ENTIRE SECTION: use the <DIV> tag to define styles globally for that section. | <DIV STYLE="font-size: 20pt; color: red"> <P> The style specification affects everything on this page until the DIV close tag. <UL> <LI>This is red and 20 pt. <LI>So is this. </UL> </DIV> |
|
|
Using STYLE within the heading area | <html> |
| STYLE within heading area uses CLASSES (now, some of the P tags on a page can be normal and some can be formatted as bold, some H1s can be red, others can be blue) |
<HEAD> H1.red {font: 15pt/17pt; <BODY> <P CLASS="myPara">This is bold text!</p> </BODY> |
|
|
Create a file called ficekStyle.css containing exactly these lines | H1, H2, H3 { font-size: 15pt; font-weight: bold; color: maroon} |
| Using that style -- put a line into the HEAD area | <HTML> <HEAD> <LINK rel="stylesheet" type="text/css" href="ficekStyle.css" title="style1"> </HEAD> |


