CSS Presentation
CSS Presentation
What is CSS?
A web application will contains hundreds of web pages, which are created
using HTML.
Formatting these HTML pages will be a laborious process, as formatting
elements need to be applied to each and every page.
CSS saves lots of work as we can change the appearance and layout of all the
web pages by editing just one single CSS file.
CSS Syntax Rules
CSS selectors allow you to select and manipulate HTML elements based on
their id, class, type, attribute, and more.
Examples –
Declaring CSS Rule For a Class Attribute
The HTML
<a class = “pdf” href=“Book.pdf”>Book</a>
The CSS
.pdf { background: url(images/pdf.gif) no-repeat left 50%;}
CSS Background
We can use CSS Background properties to define the background effects of an element.
The following properties can be used for background effects :
a. background-color
b. background-image
c. background-repeat
d. background-position
Formatting with CSS Properties
Text Formatting
The following properties can be used for formatting text :
1. Text Color
2. Text Alignment
3. Text Decoration
4. Text Transformation
5. Text Indentation
Formatting with CSS Properties
Text Alignment
We can either align the text to the left, right, center or we can make it justified.
Example
p{ text-align:left; }
h1{text-align:center;}
Text Color
The color property is used to set the color of text.
Example
body{ color:blue;}
p1 {color:magenta;}
Formatting with CSS Properties
Text Decoration
You can use text-decoration property to set or remove decorations from text.
Example
p{text-decoration:overline;}
p {text-decoration:line-through;}
p {text-decoration:underline;}
Text Transformation
You can use text-transform property to specify uppercase and lowercase letters of any text.
Example
h1{text-transform:uppercase;}
h2 {text-transform:lowercase;}
p {text-transform:capitalize;}
Formatting with CSS Properties
CSS Font
CSS font properties are used to define the font family, size, style and boldness of the text.
In CSS, there are two types of font family names:
generic family - a group of font families with a similar look (like "Serif" or
"Monospace").
font family - a specific font family (like "Times New Roman" or "Arial").
Comments in CSS
/* comment */ - This is comment used in CSS.
Formatting with CSS Properties
CSS Links
You can use CSS styles to style any link. Links can be
styled in different ways by using any CSS property like color, font-family etc.
Links can be in one of the following states :
a: link – Unvisited link
a: visited – A link that the user has visited
a: hover – A link over which the mouse pointer is moving
a: active – A link, which has been just clicked
Links can be styled according to their states.
Formatting with CSS Properties
CSS Links
Formatting with CSS Properties
CSS List
You can use CSS list properties for
Setting different list item markers for ordered lists
Setting different list item markers for unordered lists
Set an image as the list item marker
Values-
list-style-type
list-style-image
Formatting with CSS Properties
Box Model : Introduction
Box model is useful for designing the layout of an HTML Page.
CSS Box model describes a box that wraps around HTML elements.
Using this model, we can define the margins, borders, padding and the actual
content. We
can place border around elements and space elements in relation to each
other.
Formatting with CSS Properties
CSS Padding
You can use the CSS padding properties to define the space between the element border
and the element content. It is possible to change the top, right, bottom and
left padding independently using separate properties.
You can also use a shorthand padding property to change all paddings in a single statement.
Individual padding properties can be specified as follows :
padding-top:20px;
padding-bottom:30px;
padding-right:25px;
padding-left:10px;
In shorthand-
padding: 20px 30px 25px 10px;
Formatting with CSS Properties
CSS Border
You can use the CSS Border properties to specify
the style and color of an element’s border.
Values
border-style
border-width
border-color
Formatting with CSS Properties
CSS Margin
Using CSS Margin properties you can specify the space around elements.
Values:
margin-top:50px;
margin-bottom:30px;
margin-right:25px;
margin-left:10px;
In shorthand
margin:
50px 30px 25px 10px;
CSS Icons
The CSS outline properties specify the style, color, and width of an outline.
An outline is a line that is drawn around elements (outside the borders) to make the
element "stand out".
However, the outline property is different from the border property - The outline is
NOT a part of an element's dimensions; the element's total width and height is not
affected by the width of the outline.
This element has a thin black border and an outline that is 10px wide and green.
Outline Style
The outline-style property specifies the style of the outline.
The outline-style property can have one of the following values:
dotted - Defines a dotted outline
dashed - Defines a dashed outline
solid - Defines a solid outline
double - Defines a double outline
groove - Defines a 3D grooved outline. The effect depends on the outline-color value
ridge - Defines a 3D ridged outline. The effect depends on the outline-color value
inset - Defines a 3D inset outline. The effect depends on the outline-color value
outset - Defines a 3D outset outline. The effect depends on the outline-color value
none - Defines no outline
hidden - Defines a hidden outline
Cont…
The following example first sets a thin black border around each <p> element, then it shows the different
outline-style values:
Example
p{
border: 1px solid black;
outline-color: red;
}