Web Development II
Web Development II
II
Chapter 1: Introduction to CSS
Objectives
• At the end of the chapter students, should be able to:
Identify the CSS
Describe CSS syntax
Identify CSS comments
Describe the Ways to Insert of CSS
Apply the Class Selector
Use ID Selector
Compare the grouping Selectors
Explain the Position Property
What is CSS?
• CSS stands for Cascading Style Sheets.
• CSS describes how HTML elements are to be displayed on
screen, paper, or in other media.
• CSS Focusing on Design.
Why Use CSS?
• CSS is used to define styles for your web pages, including
the design, layout and variations in display for different
devices and screen sizes.
CSS Syntax
• The selector points to the HTML element you want to style.
• The declaration block contains one or more declarations separated
by semicolons.
• Each declaration includes a CSS property name and a value,
separated by a colon.
Or
p {
border-style: solid;
border-width: 25px 10px 4px 35px; /* 25px top, 10px right, 4px bottom and
35px left */
}
CSS Border Color
• The border-color property is used to set the color of the borders.
Syntax
p {
border-style: solid;
border-color: red;
}
• The border-color property can have from one to four values (for the top border, right border, bottom
border, and the left border).
p {
border-style: solid;
border-color: red green blue yellow; /* red top, green right, blue bottom
and yellow left */
}
CSS Rounded Borders
• The border-radius property is used to add rounded
borders to an element.
p {
border: 2px solid red;
border-radius: 5px;
}
CSS Margins
• The margin properties are used to create space around elements, outside of any
defined borders.
• CSS has properties for specifying the margin for each side of an element:
• margin-top
• margin-right
• margin-bottom
• margin-left
p {
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
}
The CSS Text Color
• The color property is used to set the color of the text.
body {
color: red;
}
h1 {
color: blue;
}
CSS Text Alignment
• The text-align property is used to set the horizontal
alignment of a text.
• A text can be left or right aligned, centered, or justified.
h1 {
text-align: center;
}
CSS Text Decoration
• The text-decoration-line property is used to add a decoration line to text.
h1 {
text-decoration-line: underline;
}
• The text-decoration-color property is used to set the color of the decoration line.
h1 {
text-decoration-line: underline;
text-decoration-color: green;
}
The text-decoration-style property is used to set the style of the decoration line.
h1 {
text-decoration-line: underline;
text-decoration-style: double;
}
The CSS font
• The font-family property to specify the font of a text.
p{font-family: "Times New Roman",}