CSS INTRODUCTION SLIDES WITH HTML CODE.pdf

Aasma13 20 views 32 slides May 29, 2024
Slide 1
Slide 1 of 32
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32

About This Presentation

CSS INTRO


Slide Content

CSS

DIVTaginHTML
•The<div>tag definesa divisionor a sectioninan HTMLdocument.
•The<div>tag iseasily styledbyusingthe class oridattribute.
•The HTML Content Division element (<div>) is the generic container for
flowcontent.
•It has no effect on the content or layout until styled in some way using
CSS)

Cascadingstyle-sheets(CSS)
•CreatedbyHakonLieofMITin1994
•Has become the W3C standard for controlling visual presentation of web
pages
•Cascadingstyle-sheetsarepowerfulmechanismtoaddstyletoweb
document
•Enforcestandardsanduniformity
•Createdynamiceffects
•Worksbyallowingyou tospecifyrules

AdvantagesofCSS
•Savestime
•Easytochange
•Keepconsistency
•Giveyoumorecontrolover layout
•Usestyles withJavaScript
•Makeiteasy to createa common formatfor allthe Web pages

TypesofStyleSheets
•In-linestyles
•Embedded/internalstyles
•Externalstylesheet

In-lineStyleSheet
•AddstylestoeachtagwithintheHTMLfile
•Useitwhenyouneedtoformat just a single sectionina webpage
•Style attributeisusedtoaddstyle
•Example
•<h1style=“color:red;font-family:sans-sarif;”>Thisismycontent</h1>

InternalStyleSheet
•Astyleis appliedtothe entireHTMLfile
•Useitwhenyouneedtomodifyallinstancesof particularelement(e.g.,h1)ina
webpage
•Thisisdefinebetweenheadtag
Example
<style>
h1{
color:red;
font-family:sans-serif;
}
</style>

OUTPUT

ExternalStyleSheet
•Anexternalstylesheetisatextfilecontainingthe styledefinition
(declaration)having extension.css
•Use itwhenyou needto controlthestylefor anentirewebsite
•Steps to createexternalstylesheet:-
•Openanew blankdocumentin NotepadorNotepad++
•Typestyledeclarations,Forexample:h1 {color:red;font-family:calibri;}
•Donotinclude<style>tags
•Savethedocumentasfilename.css

ExternalStyleSheet
•OpenanHTMLfile
•Between<head>and</head>add
<linkhref=URLrel=“relation_type” type=“link_type”>
•URListhefile.css
•Relation_type=“stylesheet”
•Link_type=“text/css”
•Savethisfileas.html
Forexampleif.htmlandthe .css fileare inthe same directory
<linkhref=file.cssrel=“stylesheet”type=“text/css”>

DefiningCSSRule
Aruleconsistsof
•Aselector:elementorelements the declarationapplies to
•Declaration:howthe elementsreferredto intheselectorshouldbe styled
•Property:whichisthepropertyoftheselectedelement
•Value:which isa specificationfor this property

UsingID’s
°Use an id to distinguish something, like a paragraph, from the others in a
document
°Theidselectorisused to specifya stylefor asingle, uniqueelement
°Forexample:-
°CSSfile:
°#id_name
{style attributesandvalues}
°HTMLfile
°<tagID=id_name>

UsingClasses
°HTMLandXHTMLrequireeachidbeunique–thereforeanidvaluecan
onlybeused onceina document
°You canmarka groupof elementswithacommonidentifierusingtheclass
attribute
°Tocreateaclass
•tag.class_name{styleattributes}or.class_name{styleattributes}
°Toapply astyle
•<tagCLASS=class_name>
•<h1CLASS=FirstHeader>Contentgoes here….</h1>

DifferencebetweenID’sandClasses
°Youcan’thave morethanonetagwiththesame IDvalue
°Youcanapply thesameClassvaluetomultipledocumenttags
°UseID's forany elementsthataresimplyusedonceona page
° OR
°Only use classes to style websites, but, when you have to use an element in
JavaScript,use an identifier

HTMLFile CSSFile
file.cssPage.html

OUTPUT

HTMLFile CSSFile
file.css
Page.html
Wecanusemorethanoneclassesinonetagbyusing“space”

OUTPUT

CSSFontproperties
°font-family
°font-size
°font-weight
°font-style
°font-variant

CSSFontproperties
font-family:
°Specifies the typeface or family of font that should be used
Commonvalues:
°Arial, Courier/Courier New, Georgia, Times/Times New Roman and
Verdana
Example:
h1{
font-family:arial
}

CSSFontproperties
font-size:
°Specifies the size of a font
Commonvalues:
°Inpixels(12px,20pxetc.)
°Absolutsize(small,medium,lage,x-largeetc.)
Example:
h1{
font-size:20px
}

CSSFontproperties
font-weight:
°Specifieswhetherthe fontshould beboldornormal
Commonvalues:
°Normal,bold,bolder,lighter
°100,200,300, 400,500,600,700,800,900
Example:
h1{
font-weight:bold
}

CSSFontproperties
font-style:
°Specifieswhetherthe fontshould benormal,italicor oblique
Commonvalues:
°Normal, italic, oblique
Example:
h1{
font-style:italic
}

CSSFontproperties
font-variant:
°Specifieswhetherthefontshouldbenormalorsmall-caps(smallerversion
ofuppercase)
Commonvalues:
°Normal,small-caps
Example:
h1{
font-variant :small-caps}

CSSTextproperties
°color
°text-align
°vertical-align
°text-decoration
°text-transform
°word-spacing
°letter-spacing

CSSTextproperties
°color:
•specifiesthecolorofthetext
•P{color:green}
°text-align:
•horizontalalignmentofthetext
•Left,right,centeror justify
°vertical-align:
•Verticalalignmentofthetext
•Sub,super,top,middle,bottom

CSSTextproperties
°text-decoration:
•specifiesthewhetherthetextshouldbeunderline, overline,
line-throughorblinking
°text-transform:
•text shouldbelowercase,uppercaseorcapitalized
°letter-spacing:
•Specifiesthe spacebetweenletters
•H1{letter-spacing:3px}

CSSTextproperties
°word-spacing:
•Specifiesthespacebetweenwords
•H1{word-spacing:4px}

CSSBackgroundproperties
°background-color:
•Specifiesthebackgroundcolor
°background-image:
•Specifiesthebackgroundimage
°background-repeat:
•Specifieswhetherthe image shouldrepeatornot
°background-position:
•Whereanimageshouldbepositioned

CSSBorderproperties
°border-style(solid,dashed,doted,double etc.)
°border-color
°border-bottom(solid,dashed,doted,double etc.)
°Padding-left
°Padding-right
°Padding-top
°padding-bottom
CSSPaddingproperties

Styling“HYPERLINKS”
°color:
•Changes thecolorofthe links
°background-color:
•Highlightsthelink,as ifithad beenhighlightedwith a
highlighterpen
°text-decoration:
•Underline,strikethrough,over-line, blink

Styling“HYPERLINKS”
°Pseudo-classesoflinks:
°Link:
•Stylesforlinksingeneral
°Visited:
•Stylesthelinkswhicharealready visited
°Hover:
•Styleswhensomeonhoveringoveralink
°Active:
•Stylesthelinkswhena linksisbeingclicked
Tags