CSS Introduction
CSS Introduction
of Sty le rul es for def inin g the lay out of HTM L doc um ent s. Using CSS, youcan
CSS is a sty! e she et tha t pro vid es the set
sty le of fon ts, the spa cin g bet we en par agr aph s, size and layout of colu mns,
con tro l the col our of the tex t, the
l I as a van·ety o f ot h er eff ect s. Sty le she ets are des ign ed to sep ara te t he presen tat 1·0 nstyle
· ges as we
bac kgr oun d ima
um ent s. Thi s ma kes site ma int ena nce mu ch easier and provides more
of d ocu me nts fro m the con ten t of the doc
flex ibility.
The con cre te ben efit s of CSS include:
single style she et. (Ex ter nal Style She et)
o Co ntrol la you t of ma ny doc um ent s fro m one
o Mo re pre cise con trol of layou t.
es ( screen , print; etc .)
o Ap ply dif fer ent layout to diff ere nt media typ
value
Avalue is what appears immediately after the colon in any line of CSS It is th t· h f
. • e op I0n c osen or a property.
can be font na l'k M . . .
For example: Value for the Font-family property mes I e onotype Cors1va, Times, Arial, et c.
oedaration
.
Aproperty and its value collectively are known as Declaration • Ad ec Iara t ·ion Is . .
generally any single line of CSS that
appears between the curly brace s.
Aselector is the part of the CSS line th at sel ects wh at element to target with the property/va lue pair.
For example: If we want to change the beha viou r of th e hr element (let us say its width should be 50%) then we
would use hr as our selector.
Rule
Selector and declaration, collectively are know n as Rule.
I t i t t
Hl {Co lor : blue; font-size: 20 px;} - . Rule
♦ +
ll
I I
<html> </head>
<head> <body>
<style> <hr>
hr{width:50%;height:5%;background-color:blue} </body>
</style> </html>
• BACKGROUND PROPERTIES
HTML allows you to set the background style of an element with the help of the following properti es:
BACKGROUND COLOR
This property is used to set the background colour of the HTML element.
<html><head>
<title> Using Background Color Property </title>
</body> </html>
BACKGROUND IMAGE
.,r. . J---.
(, ......,.,. --
.. KtPS
trnl>.:head>
.ch pe::: "text/css"> l o EJ ! ~
.cstYletY . "
ackground-1mage :url( C:/Users/User/D k
bodY {b · es top/Html/ +- ·➔ C Q (i) hlt :///E:/Ashtsh/HTMl/M~20F1m%20Progr... * 8 :
..,.,work.png")} ::= 4t'J'\ Fo r qud ll(UH pl.l( t y t'\l f IJ.'.X)lni, a.rli:s 1,~r~ Cr\ the ~-oomt.Yb b.,l impcrl booL;nl.!L _
rea 1
"
---·-------- ------
-- - ~~:bit ;or a person 10 reac.h the
.:/head><body>
.c/stY Ie> . . .
.cp> rearnwork is so 1mporta.n t that 1t 1s virtually impossible
erson to reach the heights of his capabilities or
fora P
n,ake the money that he wants without becoming very good at it.
CKGROUND POSITION
BA - Let's Know More
This property defines th~ position of th e background image in an HTML document. By Colou r
default, an image is placed at the top-left corner of the element. I black ~ white- Q]
red ■ blu e- - --■l
SYNTAX :background-position : value
~
yellow 0 fuc hsia
maroon ■ olive ■1
Where value= xpos ypos grey ■ purple ■I
m green
o xpos ypos - specifies t he hori zontal and vertical position respectively.
lime
aqua
orange
O navy
□ teal
:1
ai1
o xpos may be specified as left, centre, or right silver D tan □i
dodgerblue ■ firet:irick ■i
peachpuff 0 aquamar i ne □ !
O ypos may be specified as top, centre, or bottom RGB Codes
more specific position. The value for top left corner is 0% 0% and for
.,
Hexad ecimal Codes
th
~i the help of this property, we can set the repetition pattern for the background
'~age. By default, a background image is repeated in both horizontal and vertical
directions.
SYNTAX·ba
· ckground-repeat : value
Where value== no- repeatlrepeat-xlrepeat-ylrepeat
0
no repeat- image will not be repeated
0
repeat-x- image will be repeated horizontally
0
repeat-y- image will be repeated vertically
0 re d · both the directions.
Peat - default value, image will be repeate m
'-✓ - -~·
-i119J
,. ,, ~
0
. •e-. K.tPs
' w
- ~~
-~
BACKGROUND ATTACHMENT
This property helps in either fixing the image in the background or make it scroll when the user scrolls the rest oft
page. ~
SYNTAX : background-attachment: value
where value= fixed Iscroll
<html>
<title>background properties</title>
LI background pro perties X +
<head><style type="text/css" >
~ ➔ C O Ci) file:///E:/Ashish/~TML/Background%20Properties.html * e :
body{background- : : ; App~ For ~uick a::cess, place your bookmz.:k~ here on the bookmark~ bar. Import boolonarks now ...
image:url("C:/Users/User/ Desktop/Html/flower.jpg");
background-position:top center;background-repeat:
no-repeat;background-att achment:fixed}
</style></head><body> Because of
background-repeat:
Background properties related to image no-repeat, the image
1s not repeated
</body>
</html>
o HTML is the most widely used language to design web contents for the Internet.
o Internet is a network of millions of computers, which are connected to each other to share
information and resources.
o Two basic tools are required to work with HTML documents:
o HTML Ed itor for creating and saving the documents.
o Browserforviewingthedoc uments.
o HTML code is made up of elements, tags, and attributes.
o HTML elements are of 2 types
o Container elements that include both ON and OFF tag.
o Empty elements that contain only ON tag.
0 The general structure of an HTML document has 2 sections
0 Head section: It contains the title that identifies the first part of an HTML document.
0 Body section : This is the section where we do most of the work.
0 css is a style sheet that provides the set of Style rules for defining the layout of HTML documents.
0 we can include the style sheet with an HTML document in three ways:
0 IN-LINE method
0 INTERNALOREMBEDDEDSTYLESHEETmethod
0 EXTERNALSTYLESHEETmethod
I
/.i',',-
J
•: , / '_. ,·,.
,, i
. . , //~·.1
•' , , ' / / '
:~ t'.'. :;(1.io)