This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Learn about Cascading Style Sheets LACUNY Web Management Roundtable October 21, 2005 http://www.lehman.edu/provost/library/CSS/CSS.ppt
CSS Separate Style From Structure of a Web Page • Specify point size and font of text; • Set margins within a web page; • Create a distinctive style for individual web pages or sets of web pages; • Format style to one element of a web page or to a numerous pages; • Control color of different elements of a web page; • Etc. October 21, 2005
Understanding Style Rules • The style characteristics for an HTML element are expressed by Style Rules . • A set of style rules is called a Style Sheet. Sheet • Style rules are contained in the <STYLE> element in the document’s section. <Style type=“text/css”> P {color:blue; font-size: 24pt;} October 21, 2005
Understanding Style Rules • A Style Rule is composed of two parts: a selector and a declaration. Selector
Declaration
TH {color: red;}. • The Selector indicates the element to which the rule is applied. • The Declaration determines the property values of a selector. October 21, 2005
Understanding Style Rules • The Property specifies a characteristic, such as color, font-family, position, and is followed by a colon (:). • The Value expresses specification of a property, such as red for color, arial for font family, 12 pt for font-size, and is followed by a semicolon (;). Property
Using the <STYLE> Element • The <STYLE> element is always positioned in the section of the document. • The <STYLE> element always contains attribute. The value “text/css” defines the style language as Cascading Style Sheets. <Style type=“text/css”> P {color:blue; font-size: 24pt;} October 21, 2005
Using External Style Sheet • Style Rules can be expressed in an external Style Sheet - a text document that doesn’t contain any HTML code. There is no <STYLE> element in an external style sheet. • External Style Sheet has a .css extension. http://www.lehman.edu/provost/library/CSS/style_1.htm h1, h2, h3 {font-family: verdana, arial, 'sans serif'; color: #9933FF; text-align: center;} October 21, 2005
Linking to an External Style Sheet • To link a Web page to an external style sheet a element should be added within element of a document with the URL to a style sheet. It tells the browser to find a specified style sheet. <Title>Demo_1 <Style type=“text/css”> October 21, 2005
Using the Class Attribute Selector • CLASS is an HTML attribute that assigns a class name to any HTML element on a Web page. • Can be used to identify which style sheet rules should be applied for the particular element of a Web page Element
Class Selector
A.nav:link {color:#FF3300; text-decoration: none;} October 21, 2005
Using the Class Attribute Selector • A class name is created by declaring a style rule and adding (.) flag character indicating that the selector is a class selector. A.nav:link {color:#FF3300; text-decoration: none;}
• Add it to HTML code of a Web page by using the CLASS attribute. ERIC October 21, 2005