Lesson 3: XHTML Coding Objectives: Demonstrate knowledge of ...
Lesson 3: XHTML Coding Objectives: Demonstrate knowledge of ...
Lesson 3: XHTML Coding Objectives: Demonstrate knowledge of ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
HTML 4.01 and <strong>XHTML</strong> 1.0 both require that you use CSS to create the layout and<br />
formatting <strong>of</strong> your page.<br />
Before using a CSS you should learn the terminology.<br />
o There are four basic parts <strong>of</strong> a CSS rule:<br />
Selector – any element that you want to effect.<br />
Declaration – this part <strong>of</strong> a CSS rule is made up <strong>of</strong> the property and<br />
value enclosed in curly brackets.<br />
Property – this is what are you going to change about the selector.<br />
Value - this is the color or size that you are changing the particular<br />
selector to.<br />
Example rule: body {background: tan}<br />
Proper CSS Structure<br />
o A properly coded CSS rule should look similar to the one below.<br />
body {<br />
font-family: arial, verdana, helvetica; color: gray:<br />
}<br />
o Notice that the curly brackets are on separate lines and that the declaration<br />
is indented. This is considered good coding practice.<br />
o To ignore a rule in a style sheet you can comment it out. To do this place a<br />
/* before the rule and a */ after the rule.<br />
Example: /*body {background: tan}*/<br />
Inheritance<br />
o Inheritance is an essential concept <strong>of</strong> Cascading Style Sheets.<br />
o The term cascading refers to inheritance.<br />
o The styles for your CSS will cascade to the pages that are linked to it.<br />
o The rules in the style sheet will override attributes like bgcolor.<br />
CSS Facts<br />
There are four ways to apply a CSS styles:<br />
o Declare an inline style<br />
o Create an embedded style sheet<br />
o Link to an external style sheet<br />
o Use an imported style sheet - imported style sheets have been known to<br />
cause problems… certain older browsers crash when rendering pages with<br />
imported style sheets.<br />
Benefits <strong>of</strong> using a CSS<br />
o Consistency – Using a CSS makes it easy to have a consistent look and<br />
feel to your site.<br />
o Easy change management – When you need to change the color <strong>of</strong> a<br />
heading style you only have to change it on the style sheet. If you didn’t<br />
use a style sheet you would have to search for every occurrence <strong>of</strong> the<br />
heading style and change them one by one.