Beruflich Dokumente
Kultur Dokumente
What
is
a blue headline
a blue headline
Their placement
H2 {color: blue;}
selector {declaration;}
Eg: body {
font-size: 12px;
color: navy;
}
• A declaration has two parts separated by a colon: property and
value.
selector {property:value}
• More than one declaration may be placed inside the curly braces
• A semi-colon must separate each declaration from the next. The
ending declaration does not require a semi-colon
In-line
Internal
External
In-line
<html>
<head>
<title>CSS Example</title>
<style type="text/css">
p{
color: red;
}
a{
color: blue;
}
</style>
.......
External
p{
color: red;
}
a{
color: blue;
}
<html>
<head>
<title>CSS Example</title>
<link rel="stylesheet" type="text/css" href="web.css" />
...
Lengths and Percentages
• There are specific units for values used in CSS, but there are some
general units that are used in a number of properties
Such as-
• em (such as font-size: 2em)
• ex (one ex is the x-height of a font (x-height is usually about half
the font-size)
• px (such as font-size: 12px) pixels
• pt (such as font-size: 12pt) point (1 pt is the same as 1/72 inch)
• pc pica (1 pc is the same as 12 points)
• % (such as font-size: 80%)percentage
• Other units include cm (centimetres), mm (millimetres) and in
(inches).
• When a value is zero, you do not need to state a unit.
Eg:
border : 0
• Different foms:
– Name of Colour
– RGB
– HEX code
rgb(255,0,0)
rgb(100%,0%,0%)
#ff0000
#f00
• transparent is also a valid value.
• The three values in the rbg value are from 0 to 255.
• Hexadecimal is a base-16 number system.
hexadecimal has 16 digits, from 0 to f.
• The hex number is prefixed with a hash character (#) and
can be three or six digits in length.
• Basically, the three-digit version is a compressed
version of the six-digit (#f00 becomes #ff0000, #c96
becomes #cc9966 etc.).
Font-family
• The font you specify must be on the user's
computer, so there is little point in using obscure
fonts.
• The most commonly used are arial, verdana and
times new roman), but you can specify more than
one font, separated by commas.
• If the name of the font is more than one word it
should be put in quotation marks (“------“)
Font-size
The size of the font. Be careful with this - text
such as headings should not just be a paragraph
in a large font; you should still use headings (h1,
h2 etc.)
Font-weight
• This states whether the text is bold or not.
• Commonly used are font-weight: bold or font-
weight: normal. In theory it can also be bolder,
lighter, 100, 200, 300, 400, 500, 600, 700, 800 or
900
Font-style
font-style: italic or
font-style: normal.
Text-decoration
This states whether the text is underlined or not.
• text-decoration: overline
• text-decoration: line-through, strike-through,
• text-decoration: underline
( should only be used for links )
This property is usually used to decorate links,
such as specifying no underline with
• text-decoration: none.
text-transform
This will change the case of the text.
• text-transform: capitalize
• text-transform: uppercase
• text-transform: lowercase
• text-transform: none
Text spacing
• letter-spacing and word-spacing
• line-height
• text-align
• text-indent
•
Eg.
p{
letter-spacing: 2px;
word-spacing: 3px;
line-height: 4px;
text-align: center;
}
Margins and Padding
• Margins and Padding are the two most commonly used properties for
spacing-out elements.
• A margin is the space outside of the element, whereas padding is the
space inside the element.
• Eg:
h2 {
font-size: 10px;
background-color: #1F488D;
margin: 10px;
padding: 5px;
}
Padding