Lecture 12 - CSS
Lecture 12 - CSS
p { color:blue; }
Inline
Internal
External
Inline
Inline styles are applied directly to the HTML by using
the style attribute.
The following style sets the text color of the text in this
paragraph to ’blue’.
External style sheets are recommended when the styles are to be applied across
multiple HTML documents. This allows for consistency throughout an entire web site and
any style changes automatically apply to all files that include the style sheet.
If three values are provided, right and left margin are set as middle value.
If two values are provided, top and bottom margin are set as the first
value, right and left margin are set as second value.
If one value is provided, all four margin values are set the same.
margin-left
padding-right
The padding-right property sets the right padding (space) of an
element.
padding-bottom
The padding-bottom property sets the bottom padding (space)
of an element.
padding-left
The padding-left property sets the left padding (space) of an
element.
CSS Height
The height property sets the height of an element. This does
not include padding, borders, or margins.
Example
Would Display
max-height
The max-height property sets the maximum height of an
element. This does not include padding, borders, or margins.
<body>
<p>The<br />
maximum<br />
height<br />
of<br />
this<br />
paragraph<br />
is<br />
set<br />
to<br />
50px.</p>
</body>
</html>
min-height
The min-height property sets the minimum height of an element. This does not
include padding, borders, or margins.
<html>
<head>
<style>
p{
min-height:150px;
background:yellow;
}
</style>
</head>
<body>
</body>
</html>
CSS Width
width
The width property sets the width of an element, but does not
include the padding, borders, or margins.
<html>
<head>
<title>CSS Tutorial</title>
<style>
p{
min-width:350px;
background-color:yellow;
}
</style>
</head>
<body>
<p>The minimum width of this paragraph is set to 350px.</p>
</body>
</html>
max-width
The max-width property sets the maximum width of an element. This does not
include padding, borders, or margins.
Example Would Display
<html>
<head>
<title>CSS Tutorial</title>
<style>
p{
max-width:100px;
background-color:yellow;
}
</style>
</head>
<body>
<p>The maximum width of this
paragraph is set to 100px.</p>
</body>
</html>