CSS : Cascading Style Sheets
The resulting HTML page, with colours and layout, all done with CSS.
Source : http://www.w3.org/Style/Examples/011/firstcss
Source : http://www.w3.org/Style/Examples/011/firstcss
The resulting HTML page, with colors and layout, all done with CSS.
Source : http://www.w3.org/Style/Examples/011/firstcss
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>My first styled page</title> </head> <body> <!-- Site navigation menu --> <ul class="navbar"> <li><a href="index.html">Home page</a></li> <li><a href="indexS.html.html">Without</a></li> <li><a href="indexD.html">Another</a></li> <li><a href="index.html">Back</a></li> </ul> <!-- Main content --> <h1>My first styled page</h1> <p>Welcome to my styled page!</p> <p>It lacks images, but at least it has style. And it has links too</p> <p> ... blah blah ... </p> <p>There should be more here, but I don't know what yet.</p> <!-- Sign and date the page, it's only polite! --> <address>Copied 30 July 2004, from Bert Bos<br>and modified by Pascal.</address> </body> </html>
Source : http://www.w3.org/Style/Examples/011/firstcss
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>My first styled page</title>
<style type="text/css"> body { color: purple; background-color: #d8da3d } </style>
</head> <body> ../..
Source : http://www.w3.org/Style/Examples/011/firstcss
Example
body { color: purple; background-color: #d8da3d }
Source : http://www.w3.org/Style/Examples/011/firstcss
body { color: purple }
body { background-color: #d8da3d }
body { color: purple;
background-color: #d8da3d }
H1 { font-weight: bold }
H2 { font-weight: bold }
H3 { font-weight: bold }
H1, H2, H3 { font-style: bold }
Source : http://www.w3.org/Style/Examples/011/firstcss and http://www.w3.org/Style/LieBos2e/enter/
<style type="text/css">
body { font-family: Georgia, "Times New Roman",Times,
serif;
color: purple;
background-color: #d8da3d }
h1 { font-family: Helvetica, Geneva, Arial,
SunSans-Regular, sans-serif }
</style>
Source : http://www.w3.org/Style/Examples/011/firstcss
Since not all fonts are available on all computers (there are thousands of fonts, and most are not free), CSS provides a system of fallbacks. You list the font that you want first, then any fonts that might fill in for the first if it is unavailable, and you should end the list with a generic font, of which there are five: serif, sans-serif, monospace, cursive and fantasy.
After the color, the font is probably the most basic property of a page. On this page I won't show any "tricks," but I will show the range of font variations that CSS allows.
Since not all fonts are available on all computers (there are thousands of fonts, and most are not free), CSS provides a system of fallbacks. You list the font that you want first, then any fonts that might fill in for the first if it is unavailable, and you should end the list with a generic font, of which there are five: serif, sans-serif, monospace, cursive and fantasy.
The following table shows examples of various fonts (your browser may not know all of them) and you can see what your browser does with each of the five generic ones:
'sans-serif': normal fonts without serifs | |
---|---|
Verdana, sans-serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
Arial, sans-serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
Helvetica, sans-serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
Gill Sans, sans-serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
Lucida Grande, sans-serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
Helvetica Neue, sans-serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
sans-serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
'serif': normal fonts with serifs | |
Times, serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
Times New Roman, serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
Georgia, serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
Palatino, serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
New Century Schoolbook, serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
serif
| The Quick Brown Fox Jumps Over The Lazy Dog |
'monospace': fixed-width fonts | |
Andale Mono, monospace
| The Quick Brown Fox Jumps Over The Lazy Dog |
Courier New, monospace
| The Quick Brown Fox Jumps Over The Lazy Dog |
Courier, monospace
| The Quick Brown Fox Jumps Over The Lazy Dog |
Lucidatypewriter, monospace
| The Quick Brown Fox Jumps Over The Lazy Dog |
Fixed, monospace
| The Quick Brown Fox Jumps Over The Lazy Dog |
monospace
| The Quick Brown Fox Jumps Over The Lazy Dog |
'cursive': fonts that emulate handwriting | |
Comic Sans, cursive
| The Quick Brown Fox Jumps Over The Lazy Dog |
Zapf Chancery, cursive
| The Quick Brown Fox Jumps Over The Lazy Dog |
Coronetscript, cursive
| The Quick Brown Fox Jumps Over The Lazy Dog |
Florence, cursive
| The Quick Brown Fox Jumps Over The Lazy Dog |
Parkavenue, cursive
| The Quick Brown Fox Jumps Over The Lazy Dog |
cursive
| The Quick Brown Fox Jumps Over The Lazy Dog |
'fantasy': decorative fonts, for titles, etc. | |
Impact, fantasy
| The Quick Brown Fox Jumps Over The Lazy Dog |
Papyrus, fantasy
| The Quick Brown Fox Jumps Over The Lazy Dog |
Oldtown, fantasy
| The Quick Brown Fox Jumps Over The Lazy Dog |
Blippo, fantasy
| The Quick Brown Fox Jumps Over The Lazy Dog |
Brushstroke, fantasy
| The Quick Brown Fox Jumps Over The Lazy Dog |
fantasy
| The Quick Brown Fox Jumps Over The Lazy Dog |
Most fonts have various styles within the same family, typically a bold and an italic one, often also a bold italic style, somewhat less often a small-caps and in a few cases extra-light/extra-bold or stretched/condensed versions.
The table below shows a number of different styles. Unless you have a very rich collection of fonts, many of the rows will be the same.
rule | serif | sans-serif | |||
---|---|---|---|---|---|
Styles | |||||
font-style: normal
| The Quick… | The Quick… | |||
font-style: italic
| The Quick… | The Quick… | |||
font-style: oblique
| The Quick… | The Quick… | |||
Weights | |||||
font-weight: 100
| The Quick… | The Quick… | |||
font-weight: 200
| The Quick… | The Quick… | |||
font-weight: 300
| The Quick… | The Quick… | |||
font-weight: normal
| The Quick… | The Quick… | |||
font-weight: 500
| The Quick… | The Quick… | |||
font-weight: 600
| The Quick… | The Quick… | |||
font-weight: bold
| The Quick… | The Quick… | |||
font-weight: 800
| The Quick… | The Quick… | |||
font-weight: 900
| The Quick… | The Quick… | |||
Variants | |||||
font-variant: normal
| The Quick… | The Quick… | |||
font-variant: small-caps
| The Quick… | The Quick… | |||
Stretch | |||||
font-stretch: ultra-condensed
| The Quick… | The Quick… | |||
font-stretch: extra-condensed
| The Quick… | The Quick… | |||
font-stretch: condensed
| The Quick… | The Quick… | |||
font-stretch: semi-condensed
| The Quick… | The Quick… | |||
font-stretch: normal
| The Quick… | The Quick… | |||
font-stretch: semi-expanded
| The Quick… | The Quick… | |||
font-stretch: expanded
| The Quick… | The Quick… | |||
font-stretch: extra-expanded
| The Quick… | The Quick… | |||
font-stretch: ultra-expanded
| The Quick… | The Quick… |
In CSS3, there is one more style available: 'font-effect' makes the letters look engraved or embossed.
body { padding-left: 11em;
font-family: Georgia, "Times New Roman",
Times, serif;
color: purple;
background-color: #d8da3d }
ul.navbar {
position: absolute;
top: 2em;
left: 1em;
width: 9em }
The 'position: absolute' says that the ul element is
positioned independently of any text that comes before or after it in the document
and the 'left' and 'top' indicate what that position is. In this case, 2em from
the top and 1em from the left side of the window.
'2em' means 2 times the size of the current font. E.g., if the menu is displayed
with a font of 12 points, then '2em' is 24 points. The 'em' is a very useful
unit in CSS, since it can adapt automatically to the font that the reader happens
to use. Most browsers have a menu for increasing or decreasing the font size:
you can try it and see that the menu increases in size as the font increases,
which would not have been the case, if we had used a size in pixels instead.
Source : http://www.w3.org/Style/Examples/011/firstcss
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<h1>Test</h1>
<p>
Paragraph
</p>
<p>Another paragraph</p>
</body>
Source : http://www.w3.org/Style/Examples/011/firstcss
body { padding-left: 11em;
font-family: Georgia, "Times New Roman",
Times, serif;
color: purple;
background-color: #d8da3d }
ul.navbar {
position: absolute;
top: 2em;
left: 1em;
width: 9em }
The 'position: absolute' says that the ul element is
positioned independently of any text that comes before or after it in the document
and the 'left' and 'top' indicate what that position is. In this case, 2em from
the top and 1em from the left side of the window.
'2em' means 2 times the size of the current font. E.g., if the menu is displayed
with a font of 12 points, then '2em' is 24 points. The 'em' is a very useful
unit in CSS, since it can adapt automatically to the font that the reader happens
to use. Most browsers have a menu for increasing or decreasing the font size:
you can try it and see that the menu increases in size as the font increases,
which would not have been the case, if we had used a size in pixels instead.
Source : http://www.w3.org/Style/Examples/011/firstcss
ul.navbar {
list-style-type: none;
padding: 0;
margin: 0;
position: absolute;
top: 2em;
left: 1em;
width: 9em }
Source : http://www.w3.org/Style/Examples/011/firstcss
ul.navbar li {
background: white;
margin: 0.5em 0;
padding: 0.3em;
border-right: 1em solid black }
ul.navbar a {
text-decoration: none }
a:link {
color: blue }
a:visited {
color: purple }
Source : http://www.w3.org/Style/Examples/011/firstcss
To learn more about selectors : http://westciv.com/style_master/academy/css_tutorial/selectors/index.html
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<h1>Test</h1>
<p>
Paragraph
</p>
<p>Another paragraph</p>
</body>
To learn more about selectors : http://westciv.com/style_master/academy/css_tutorial/selectors/index.html
To learn more about selectors : http://westciv.com/style_master/academy/css_tutorial/selectors/index.html
ul.navbar li {
background: white;
margin: 0.5em 0;
padding: 0.3em;
border-right: 1em solid black }
ul.navbar a {
text-decoration: none }
a:link {
color: blue }
a:visited {
color: purple }
Source : http://www.w3.org/Style/Examples/011/firstcss
address { |
Source : http://www.w3.org/Style/Examples/011/firstcss
<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>My first styled page</title>
<link rel="stylesheet"
type="text/css"
href="mystyle.css">
</head>
<body> ../..
Source : http://www.w3.org/Style/Examples/011/firstcss
body { margin-left: 10%; margin-right: 10%; } h1 { margin-left: -8%; } h2,h3,h4,h5,h6 { margin-left: -4%; }
h1 { font-size: 200%; } h2 { font-size: 150%; }
<h2>Spring in Wiltshire</h2>
<p>Blossom on the trees, bird song and the sound of lambs bleating in the fields.</p>
body { background-attachment: fixed; background-image: URL(panel.gif); background-repeat: repeat-y; }
This specification defines Cascading Style Sheets, level
2.1 (CSS2). CSS2 is a style sheet language that allows authors and users to
attach style (e.g., fonts, spacing, and aural cues) to structured documents
(e.g., HTML documents and XML applications). By separating the presentation
style of documents from the content of documents, CSS2 simplifies Web authoring
and site maintenance.
CSS2 builds on CSS1 and, with very few exceptions, all valid CSS1 style sheets
are valid CSS2 style sheets. CSS2 supports media-specific style sheets so that
authors may tailor the presentation of their documents to visual browsers, aural
devices, printers, braille devices, handheld devices, etc. This specification
also supports content positioning, downloadable fonts, table layout, features
for internationalization, automatic counters and numbering, and some properties
related to user interface.
Source : http://www.cs.tcd.ie/Benjamin.Jung/Download/QuickReference/CSS-2/
Cascading Style Sheets is formally described in two specifications
from W3C: CSS1 and CSS2. CSS1 was issued in December 1996 and describes a simple
formatting model mostly for screen-based presentations. CSS1 has around 50 properties
(for example color and font-size). CSS2 was finalized in May 1998 and builds
on CSS1. CSS2 includes all CSS1 properties and adds around 70 of its own, such
as properties to describe aural presentations and page breaks. The CSS specifications
:
W3C CSS1 : http://www.w3.org/TR/REC-CSS1
W3C CSS2 : http://www.w3.org/TR/REC-CSS2
Source : http://www.w3.org/Style/LieBos2e/enter/