What Is CSS?: CSS Stands For Cascading Style Sheets
What Is CSS?: CSS Stands For Cascading Style Sheets
CSS Selectors
CSS selectors allow you to select and manipulate HTML elements.
The id Selector
The id selector uses the id attribute of an HTML element to select a specific element.
#para1 {
text-align: center;
color: red;
}
The rel attribute specifies the relationship between the current document and the linked
document. Only used if the href attribute is present.
3.Inline Styles
An inline style may be used to apply a unique style for a single element.
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>
1.CSS Background
CSS background properties are used to define the background effects of an element.
CSS properties used for background effects:
background-color
background-image
background-repeat
background-attachment
background-position
body {
background-color: #b0c4de;
background-image: url("paper.gif");
background-repeat: repeat-x;
//To repeat an image vertically set background-repeat: repeat-y;
background-position: right top;
//set as background-repeat: no-repeat;
}
background-color
background-image
background-repeat
background-attachment
background-position
It does not matter if one of the property values is missing, as long as the ones that are present are in this
order.
2.CSS Text
Body {
color: blue;
}
h1 {
text-align: center;
//The text-align property is used to set the horizontal alignment of a text. Text
can be centered, or aligned to the left or right, or justified.
}
a{
text-decoration: none; // The text-decoration property is mostly used to remove underlines
}
from links for design purposes: It can also be used to decorate
text: overline, line-through, underline ;
3.CSS Links
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user mouses over it
a:active - a link the moment it is clicked
a:hover MUST come after a:link and a:visited
a:active MUST come after a:hover
4.CSS Lists
list-style
list-style-image
5.CSS Tables
Table Borders
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
padding: 25px;
border: 25px solid navy;
margin: 25px;
}
Four values: first value applies to top-left, second value applies to top-right, third value applies
o bottom-right, and fourth value applies to bottom-left corner
Three values: first value applies to top-left, second value applies to top-right and bottom-left,
and third value applies to bottom-right
Two values: first value applies to top-left and bottom-right corner, and the second value applies
to top-right and bottom-left corner
One value: all four corners are rounded equally
#rcorners4{
border-radius: 15px 50px 30px 5px;
}
border-radius
border-top-left-radius
border-top-right-radius
border-bottom-right-radius
border-bottom-left-radius
CSS3 Backgrounds
CSS3 properties:
background-size
background-origin
background-clip
CSS3 allows you to add multiple background images for an element, through the background-image
property.
#example1 {
background-image: url(img_flwr.gif), url(paper.gif);
background-position: right bottom, left top;
background-repeat: no-repeat, repeat;
}
shorthand property
#example1 {
background: url(img_flwr.gif) right bottom no-repeat, url(paper.gif) left top repeat;
}
background-size property allows you to specify the size of background images. The size can be
specified lengths, contain or cover.
background-size: 100px 80px;
background-size: contain;
background-size: cover;
background-origin property specifies where the background image is positioned.
border-box - the background image starts from the upper left corner of the border
padding-box - (default) the background image starts from the upper left corner of the padding
edge
content-box - the background image starts from the upper left corner of the content
background-origin: content-box;
background-origin: border-box;
background-clip property specifies the painting area of the background.
border-box - (default) the background is painted to the outside edge of the border
padding-box - the background is painted to the outside edge of the padding
content-box - the background is painted within the content box
background-clip: content-box;
background-clip:padding-box;