<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body style="background-color: #ca0164;"> <h1 style="font-size: 40px;">This is a Headline</h1> <p>This is a Paragraph.</p> </body> </html>
<!DOCTYPE html> <html> <head> <title>Page Title</title> <style> body { background-color: #ca0164; } h1 { font-size: 40px; } </style> </head> <body> <h1>This is a Headline</h1> <p>This is a Paragraph.</p> </body> </html>
<!DOCTYPE html> <html> <head> <title>Page Title</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1>This is a Headline</h1> <p>This is a Paragraph.</p> </body> </html>
<body> <div class="main"> <h1>Headline</h1> <p>This is a Paragraph.</p> <p>This is a Paragraph.</p> </div> <div class="sidebar"> <h2>Headline</h2> <p>This is a Paragraph.</p> <p>This is a Paragraph.</p> </div> </body>
body { background-color: #ca0164; } p { font-size: 20px; }
<body> <div id="main"> <h1>Headline</h1> <div class="teaser"> <h2>Subhead</h2> <p>Paragraph.</p> <p>Paragraph.</p> </div> <div class="teaser"> <h2>Subhead</h2> <p>Paragraph.</p> <h3>Sub-Subhead</h3> <p>Paragraph.</p> </div> </div> <div id="sidebar"> <h2>Headline</h2> <p>Paragraph.</p> <p>Paragraph.</p> </div> </body>
.teaser { color: #333333; }
<body> <div id="main"> <h1>Headline</h1> <div class="teaser"> <h2>Subhead</h2> <p>Paragraph.</p> <p>Paragraph.</p> </div> <div class="teaser"> <h2>Subhead</h2> <p>Paragraph.</p> <h3>Sub-Subhead</h3> <p>Paragraph.</p> </div> </div> <div id="sidebar"> <h2>Headline</h2> <p>Paragraph.</p> <p>Paragraph.</p> </div> </body>
#main { width: 75%; float: left; } #sidebar { width: 25%; float: left; }
<body> <div id="main"> <h1>Headline</h1> <div class="teaser"> <h2>Subhead</h2> <p>Paragraph.</p> <p>Paragraph.</p> </div> <div class="teaser"> <h2>Subhead</h2> <p>Paragraph.</p> <h3>Sub-Subhead</h3> <p>Paragraph.</p> </div> </div> <div id="sidebar"> <h2>Headline</h2> <p>Paragraph.</p> <p>Paragraph.</p> </div> </body>
#main { width: 75%; } #sidebar { width: 25%; } #main, #sidebar { float: left; }
Pseudo classes are frequently used to style links in different states.
a { color: red; }
a:link { color: orange; }
a:visited { color: yellow; }
a:hover { color: green; }
a:active { color: blue; }
a:focus { color: purple; }
<body> <div id="main"> <h1>Headline</h1> <div class="teaser"> <h2>Subhead</h2> <p>Paragraph.</p> <p>Paragraph.</p> </div> <div class="teaser"> <h2>Subhead</h2> <p>Paragraph.</p> <h3>Sub-Subhead</h3> <p>Paragraph.</p> </div> </div> <div id="sidebar"> <h2>Headline</h2> <p>Paragraph.</p> <p>Paragraph.</p> </div> </body>
h2 { color: green; } .teaser h2 { color: red; }
Properties are the part of a CSS declaration that indicates the type of style that will be applied.
See a full list of CSS properties that are available from the Mozilla Developer Network.