I. Overview
CSS defines attributes to specify the font, color, margin, border, background picture, how text is to be, element size, and element position.
1 Font-weight:bold; 2 margin-left:10%; /* the left margin is the 10% of the page width */ 3 text-indent:.5in; /* 1/2 inch Indent */ 4 font-size:12pt; /* Font size 12pt */
Method of referencing a style:
1. Inline style
2. Use the <style> and </style> tags to pick up a CSS style sheet and put it in the
3. Save in a separate file, use the <link> tag in the
1 <link rel= ' stylesheet ' href= ' demo.css ' type= ' text/css '/>
Second, CSS History
CSS1 was adopted in December 1996, and he defined specific colors, fonts, margins, borders, and other basic styles.
CSS2 was adopted in May 1998 and defines many advanced features, most notably the absolute positioning of supporting elements.
CSS2.1 clarified and corrected the CSS2, and it removed features that the browser vendor had never implemented. Modern browsers basically fully support CSS2.1, but there are some missing issues with IE below IE8.
CSS3 the CSS into smaller modules.
Third, composite properties
1 font:bold Italic 24pt Helvetica;
Iv. Non-standard attributes
When browser vendors implement non-standard CSS properties, they add a vendor prefix to the property name.
firefox-moz-
chrome-webkit-
ie-ms-
opera-o-
V. CSS Examples
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= ' Utf-8 '/>5 <title>Demo</title>6 <style>7 H1,H2{8 Color:Blue;9 Font-style:Italic;Ten text-align:Center; One } A . WARNING{ - Font-weight:Bold; - font-size:150%; the margin:0 1in 0 1in; - background:Yellow; - Border:Solid Red 8px; - padding:10px; + } - #special{ + text-align:Center; A Text-transform:Uppercase; at } - </style> - </Head> - - <Body> - in <H1>Cascading Style Sheets Demo</H1> - to <Divclass= ' WARNING '> + <H2>Warning</H2> - This is a warning! the Notice How it grabs your attention with its bold text and bright colors. * Also Notice that the heading are centered and in blue italics. $ </Div>Panax Notoginseng - <PID= "Special"> theThis paragraph is centered<BR/> +and appears in uppercase letters.<BR/> A <spanstyle= "Text-transform:none;"> the Here we explicitly use a inline style to override the uppercase letters. + </span> - </P> $ $ </Body> - </HTML>
Browser Run Results:
Scripting CSS (i)-CSS Overview