Lesson 5 - Web Development
Lesson 5 - Web Development
Lesson 5 - Web Development
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
Inline style
<h1 style="color:blue;margin-left:30px;">This is a
heading</h1>
External style sheet
• With an external style sheet, you can change the
look of an entire website by changing just one file!
Example
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
CSS Colors
• Colors are specified using predefined color names, or RGB, HEX, HSL,
RGBA, HSLA values.
Examples include
• Tomato
• Orange
• DodgerBlue
• MediumSeaGreen
• Gray
• SlateBlue
• Violet
• LightGray
CSS Colours
Background Color
• You can set the background color for HTML
elements:
<h1 style="background-color:DodgerBlue;">Hello
World</h1>
<p style="background-color:Tomato;">Lorem
ipsum...</p>
CSS Colours
Text Color
• You can set the color of text:
Example
<h1 style="color:Tomato;">Hello World</h1>
Border Color
• You can set the color of borders:
Example
• <h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello
World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>
CSS Colours
Color Values
• In HTML, colors can also be specified using
RGB values, HEX values, HSL values, RGBA
values, and HSLA values:
RGB Value
• In HTML, a color can be specified as an RGB
value, using this formula:
• rgb(red, green, blue)
CSS Colours
HEX Value
• In HTML, a color can be specified using a
hexadecimal value in the form:
• #rrggbb
RGBA Value
• RGBA color values are an extension of RGB color
values with an alpha channel - which specifies the
opacity for a color.
• An RGBA color value is specified with:
• rgba(red, green, blue, alpha)
CSS Borders
• The CSS border properties allow you to specify
the style, width, and color of an element's
border.
• The border-style property specifies what kind of
border to display.
Border Width
• The border-width property specifies the width
of the four borders.
• The width can be set as a specific size (in px, pt,
cm, em, etc) or by using one of the three pre-
defined values: thin, medium, or thick.
CSS Borders
Border Width
• The border-width property specifies the width of the four borders.
• The width can be set as a specific size (in px, pt, cm, em, etc) or by using one of
the three pre-defined values: thin, medium, or thick.
p.one {
border-style: solid;
border-width: 5px;
}
p.two {
border-style: solid;
border-width: medium;
}
p.three {
border-style: solid;
border-width: 2px 10px 4px 20px;
}
CSS Borders
Border Color
• The border-color property is used to set the color of the four
borders.
p.one {
border-style: solid;
border-color: red;
}
p.two {
border-style: solid;
border-color: green;
}
p.three {
border-style: solid;
border-color: red green blue yellow;
}
CSS Borders
Border - Shorthand Property
• There are many properties to consider when dealing with borders and to
shorten the code, it is also possible to specify all the individual border
properties in one property.
Example
p {
border: 5px solid red;
}
CSS Border
Rounded Borders
• The border-radius property is used to add
rounded borders to an element:
Example
p {
border: 2px solid red;
border-radius: 5px;
}
CSS Box Model
• All HTML elements can be considered as
boxes. In CSS, the term "box model" is used
when talking about design and layout.
The box model allows us to add a border around elements, and to define
space between elements.
Example
• div {
width: 300px;
border: 25px solid green;
padding: 25px;
margin: 25px;
}
Selectors
• A selector designates exactly which element or
elements within our HTML to target and apply
styles (such as color, size, and position) to.
p { ... }