尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
How CSS works
By Amit Tyagi
a.webdevninja@gmail.com
What is CSS
• Cascading Style Sheets
• Contains the rules for the presentation of
HTML.
+ =
HTML CSS Web Page
• CSS was introduced to keep the
presentation information separate from
HTML markup (content).
Before CSS
• Initially Designers used presentation tags like (FONT, B, BR, TABLE
etc.) and spacers GIFs to control the design of web pages.
• Any modification in the design of websites
was a very difficult and boring task , as it
evolves manually editing every HTML
page.
Providing support for multiple browsers was a
difficult task.
CSS – brief history
• Style sheets have existed in one form or
another since the beginnings of SGML in
the 1970s.
• In 1996, CSS level 1 Recommendation
was published in December.
• CSS level2 was published as a W3C
Recommendation on May 12, 1998
• CSS level3 is still under development.
Sources of Styles
Author (developer) Styles
• Inline Styles - As inline attribute “style” inside HTML tags
<div style=“font-weight: bold;”>I am bold</div>
• Embedded Styles - As embedded style tag with in HTML
document.
<html>
<head>
<title>Welcome to Vendio!</title>
<style>
.footer {
width:90%;
}
</style>
</html>
• Linked Styles - Inside separate files with .css extension
<link rel="stylesheet" href=“external.css" type="text/css" />
Sources of Styles(contd.)
• User Style sheets
This file contains the user created styles .
[firefox profile folder]/
chrome/userContent-example.css is the
current user’s style sheet file for the
firefox.
• Browser default style sheet
This file contains default styles for all users of a
browser
[firefox folder]/res/html.css is the
default style sheet file for the firefox.
Cascade
The CSS cascade assigns a weight
to each style rule. When several
rules apply, the one with the
greatest weight takes precedence.
Order of preference for various
styles:
– Default browser style sheet
(weakest)
– User style sheet
– Author style sheet
– Author embedded styles
– Author inline styles (strongest)
CSS Selectors
• ID based ( #)
HTML
<div id=“content”>
Text
</div>
CSS
#content {
width: 200px;
}
ID selectors should be used with single elements.
Class based selector
• Class (.)
HTML
<div class=“big”>
Text
</div>
<div>
CSS
.content {
width: 200px;
}
<span class=“big”>some text </span>
</div>
Class based styles can be used by multiple HTML elements.
Tag based selectors
• Tag (Tag name)
HTML CSS
<div> DIV {
Text width: 200px;
</div> }
<div> SPAN {
<span>some text </span> font-size:130%;
</div> }
<span>some other text </span>
Grouping
• Multiple selectors can be grouped in a
single style declaration by using , .
H1, P , .main {
font-weight:bold;
}
Descendant selectors
Descendant selectors are used to select elements that
are descendants (not necessarily children) of another
element in the document tree.
CSS
DIV.abc P {
font-weight:bold;
}
HTML
<div class=“abc”>
<div>
<P>
Hello there!
</p>
</div>
</div>
Child selectors
A child selector is used to select an element that is a
direct child of another element (parent). Child selectors
will not select all descendants, only direct children.
CSS
DIV.abc > P {
font-weight:bold;
}
HTML
<div >
<div class=“abc”>
<P>
Hello there!
</p>
</div>
</div>
Universal selectors
Universal selectors are used to select any
element.
* {
color: blue;
}
Adjacent sibling selectors
Adjacent sibling selectors will select the
sibling immediately following an element.
DIV.abc + P {
font-weight: bold;
}
will work for
<div>
<div class=“abc”>Message</div>
<P>Hello there!</p>
</div>
Attribute selectors
Attribute selectors selects elements based
upon the attributes present in the HTML
Tags and their value.
IMG[src="small.gif"] {
border: 1px solid #000;
}
will work for
<img src=“small.gif” />
CSS Pseudo-classes
selector:pseudo-class { property: value }
:link
:visited
:hover
:active
} Link (A tag) related pseudo classes
:after
:before
:first-child
:focus
:first-letter
:first-line
:lang
CSS Values
• Words: text-align:center;.
• Numerical values: Numerical values are usually
followed by a unit type.
font-size:12px;
12 is the numerical value and px is the unit type pixels.
– Absolute Values – in, pc, px, cm, mm, pt
– Relative Values – em, ex, %
• Color values: color:#336699 or color#369.
Categories of CSS properties
• Positioning and layout handling related.
• Background related properties.
• Font and text related
• Links related.
• Lists related.
• Table related.
Box model
The Display Property
• Block Level elements, such as DIVs, paragraphs, headings, and
lists, sit one above another when displayed in the browser.
HTML
<body>
<div id=“div1”></div>
<div id=“div2”></div>
<div id=“div3”></div>
</body>
CSS
#div1 { width:300px;background:yellow;}
#div1 { width:300px;background:blue;}
#div1 { width:300px;background:orange;}
Inline Elements
• Inline elements such as a, span, and img, sit side by side when
they are displayed in the browser and only appear on a new line if
there is insufficient room on the previous one.
<div id="row1" >
<span class="norm">This is
small text and </span>
<span class="big">this is big</
span>
<span class="italicText"> I am
Italic</span>
</div>
.norm {
color:red;
}
.big {
color:blue;
font-weight:bold;
}
.italicText {
color:green;
font-style:italic;
}
#row1 {
padding:10px;
border:solid 1px #000;
}
Display property
none
block
run-in
marker
inline-table
table-row-group
table-footer-group
table-column-group
table-cell
inline
list-item
compact
table
inline-block
table-header-group
table-row
table-column
table-caption
Visibility
Visible : The element is visible (default).
Hidden : The element is invisible (but still takes up space)
.big {
visibility:hidden;
}
z-index
The z-index property specifies the stack order of an element.
An element with greater stack order is always in front of an
element with a lower stack order.
only works on positioned elements (position:absolute,
position:relative, or position:fixed).
Default page flow
Always think of web page as 3D arrangement
of different layers.
Floating
float:left, right, none;
A floated box is laid out according to the normal flow, then taken out
of the flow and shifted to the left or right as far as possible.
IMG
{
left;
}
float:
Floating multiple elements
Floated boxes will move to the left or right until their outer edge
touches the containing block edge or the outer edge of another float.
<ul>
<li>Home</li>
<li>Products</li>
<li>Services</li>
<li>Contact Us</li>
</ul>
After applying
LI {
float:left;
}
Clearing Floats
Clear:both ;
Or
<style type="text/css">
.clearfix:after {
content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.clearfix {display: inline-block;} /* for IE/Mac */
</style>
<!--[if IE]><style type="text/css">
.clearfix { zoom: 1; display: block; }
</style> <![endif]-->
Positioning - static
position:static; (Default option) the element occurs in the normal
flow (ignores any top, bottom, left, right, or z-index declarations)
Positioning - relative
position:relative; Generates a relatively positioned element,
positioned relative to its normal position, use bottom, right, top
and left property to place element. Default flow of other elements
don’t change.
Positioning - absolute
position:relative; Generates an absolutely positioned element,
positioned relative to the first parent element that has a position
other than static (if none is found, relative to document’s BODY).
use bottom, right, top and left property to place element
Positioning - fixed
position:relative; Generates an absolutely positioned element,
positioned relative to the browser window and don’t change
even after page scroll. use bottom, right, top and left property to
place element
Inheritance
• Styles that relate to text and appearance
are inherited by the descendant
elements.
• Styles that relate to the appearance of
boxes created by styling DIVs,
paragraphs, and other elements, such as
borders, padding, margins are not
inherited.
Refrences
• www.w3schools.com
• www.w3.org
• World wide web

More Related Content

What's hot

Css ppt
Css pptCss ppt
Css ppt
Nidhi mishra
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
Evolution Network
 
4. Web Technology CSS Basics-1
4. Web Technology CSS Basics-14. Web Technology CSS Basics-1
4. Web Technology CSS Basics-1
Jyoti Yadav
 
CSS
CSSCSS
Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)
Reshmi Rajan
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
Ferdous Mahmud Shaon
 
Cascading style sheets - CSS
Cascading style sheets - CSSCascading style sheets - CSS
Cascading style sheets - CSS
iFour Institute - Sustainable Learning
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Basic css
Basic cssBasic css
Basic css
Gopinath Ambothi
 
CSS
CSSCSS
Week 12 CSS - Review from last week
Week 12 CSS - Review from last weekWeek 12 CSS - Review from last week
Week 12 CSS - Review from last week
Katherine McCurdy-Lapierre, R.G.D.
 
FFW Gabrovo PMG - CSS
FFW Gabrovo PMG - CSSFFW Gabrovo PMG - CSS
FFW Gabrovo PMG - CSS
Toni Kolev
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
Singsys Pte Ltd
 
FFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLFFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTML
Toni Kolev
 
Css
CssCss
Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)
Harshil Darji
 
Week11 Lecture: CSS
Week11 Lecture: CSSWeek11 Lecture: CSS
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
AursalanSayed
 
Html
HtmlHtml

What's hot (20)

Css ppt
Css pptCss ppt
Css ppt
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
4. Web Technology CSS Basics-1
4. Web Technology CSS Basics-14. Web Technology CSS Basics-1
4. Web Technology CSS Basics-1
 
CSS
CSSCSS
CSS
 
Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Cascading style sheets - CSS
Cascading style sheets - CSSCascading style sheets - CSS
Cascading style sheets - CSS
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
Basic css
Basic cssBasic css
Basic css
 
CSS
CSSCSS
CSS
 
Week 12 CSS - Review from last week
Week 12 CSS - Review from last weekWeek 12 CSS - Review from last week
Week 12 CSS - Review from last week
 
FFW Gabrovo PMG - CSS
FFW Gabrovo PMG - CSSFFW Gabrovo PMG - CSS
FFW Gabrovo PMG - CSS
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
FFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLFFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTML
 
Css
CssCss
Css
 
Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)
 
Week11 Lecture: CSS
Week11 Lecture: CSSWeek11 Lecture: CSS
Week11 Lecture: CSS
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Html
HtmlHtml
Html
 

Similar to Howcssworks 100207024009-phpapp01

howcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptxhowcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptx
RavneetSingh343801
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
smithaps4
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
Doncho Minkov
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
smitha273566
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
William Myers
 
DHTML
DHTMLDHTML
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
Tanu524249
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 
Cascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptxCascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptx
alvindalejoyosa1
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSSCascading Style Sheets - CSS
Cascading Style Sheets - CSS
Sun Technlogies
 
Css
CssCss
Web Development - Lecture 5
Web Development - Lecture 5Web Development - Lecture 5
Web Development - Lecture 5
Syed Shahzaib Sohail
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
Abhishek Kesharwani
 
Css
CssCss
CSS.pptx
CSS.pptxCSS.pptx
CSC PPT 9.pptx
CSC PPT 9.pptxCSC PPT 9.pptx
CSC PPT 9.pptx
DrRavneetSingh
 
Css basics
Css basicsCss basics
Css basics
ASIT
 
Web topic 15 1 basic css layout
Web topic 15 1  basic css layoutWeb topic 15 1  basic css layout
Web topic 15 1 basic css layout
CK Yang
 

Similar to Howcssworks 100207024009-phpapp01 (20)

howcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptxhowcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptx
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
DHTML
DHTMLDHTML
DHTML
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
 
Cascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptxCascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptx
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSSCascading Style Sheets - CSS
Cascading Style Sheets - CSS
 
Css
CssCss
Css
 
Web Development - Lecture 5
Web Development - Lecture 5Web Development - Lecture 5
Web Development - Lecture 5
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
 
Css
CssCss
Css
 
CSS.pptx
CSS.pptxCSS.pptx
CSS.pptx
 
CSC PPT 9.pptx
CSC PPT 9.pptxCSC PPT 9.pptx
CSC PPT 9.pptx
 
Css basics
Css basicsCss basics
Css basics
 
Web topic 15 1 basic css layout
Web topic 15 1  basic css layoutWeb topic 15 1  basic css layout
Web topic 15 1 basic css layout
 

Recently uploaded

Diversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT KanpurDiversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Quiz Club IIT Kanpur
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Kalna College
 
Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024
khabri85
 
Decolonizing Universal Design for Learning
Decolonizing Universal Design for LearningDecolonizing Universal Design for Learning
Decolonizing Universal Design for Learning
Frederic Fovet
 
Information and Communication Technology in Education
Information and Communication Technology in EducationInformation and Communication Technology in Education
Information and Communication Technology in Education
MJDuyan
 
IoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdfIoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdf
roshanranjit222
 
How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17
Celine George
 
Creating Images and Videos through AI.pptx
Creating Images and Videos through AI.pptxCreating Images and Videos through AI.pptx
Creating Images and Videos through AI.pptx
Forum of Blended Learning
 
A Quiz on Drug Abuse Awareness by Quizzito
A Quiz on Drug Abuse Awareness by QuizzitoA Quiz on Drug Abuse Awareness by Quizzito
A Quiz on Drug Abuse Awareness by Quizzito
Quizzito The Quiz Society of Gargi College
 
Creativity for Innovation and Speechmaking
Creativity for Innovation and SpeechmakingCreativity for Innovation and Speechmaking
Creativity for Innovation and Speechmaking
MattVassar1
 
Keynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse CityKeynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse City
PJ Caposey
 
How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...
Infosec
 
bryophytes.pptx bsc botany honours second semester
bryophytes.pptx bsc botany honours  second semesterbryophytes.pptx bsc botany honours  second semester
bryophytes.pptx bsc botany honours second semester
Sarojini38
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
nutrition in plants chapter 1 class 7...
nutrition in plants chapter 1 class 7...nutrition in plants chapter 1 class 7...
nutrition in plants chapter 1 class 7...
chaudharyreet2244
 
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
biruktesfaye27
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
ShwetaGawande8
 
The Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teachingThe Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teaching
Derek Wenmoth
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity
RuchiRathor2
 

Recently uploaded (20)

Diversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT KanpurDiversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT Kanpur
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
 
Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024
 
Decolonizing Universal Design for Learning
Decolonizing Universal Design for LearningDecolonizing Universal Design for Learning
Decolonizing Universal Design for Learning
 
Information and Communication Technology in Education
Information and Communication Technology in EducationInformation and Communication Technology in Education
Information and Communication Technology in Education
 
IoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdfIoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdf
 
How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17
 
Creating Images and Videos through AI.pptx
Creating Images and Videos through AI.pptxCreating Images and Videos through AI.pptx
Creating Images and Videos through AI.pptx
 
A Quiz on Drug Abuse Awareness by Quizzito
A Quiz on Drug Abuse Awareness by QuizzitoA Quiz on Drug Abuse Awareness by Quizzito
A Quiz on Drug Abuse Awareness by Quizzito
 
Creativity for Innovation and Speechmaking
Creativity for Innovation and SpeechmakingCreativity for Innovation and Speechmaking
Creativity for Innovation and Speechmaking
 
Keynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse CityKeynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse City
 
How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...
 
bryophytes.pptx bsc botany honours second semester
bryophytes.pptx bsc botany honours  second semesterbryophytes.pptx bsc botany honours  second semester
bryophytes.pptx bsc botany honours second semester
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
nutrition in plants chapter 1 class 7...
nutrition in plants chapter 1 class 7...nutrition in plants chapter 1 class 7...
nutrition in plants chapter 1 class 7...
 
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
 
The Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teachingThe Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teaching
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity
 

Howcssworks 100207024009-phpapp01

  • 1. How CSS works By Amit Tyagi a.webdevninja@gmail.com
  • 2. What is CSS • Cascading Style Sheets • Contains the rules for the presentation of HTML. + = HTML CSS Web Page • CSS was introduced to keep the presentation information separate from HTML markup (content).
  • 3. Before CSS • Initially Designers used presentation tags like (FONT, B, BR, TABLE etc.) and spacers GIFs to control the design of web pages.
  • 4. • Any modification in the design of websites was a very difficult and boring task , as it evolves manually editing every HTML page.
  • 5. Providing support for multiple browsers was a difficult task.
  • 6. CSS – brief history • Style sheets have existed in one form or another since the beginnings of SGML in the 1970s. • In 1996, CSS level 1 Recommendation was published in December. • CSS level2 was published as a W3C Recommendation on May 12, 1998 • CSS level3 is still under development.
  • 7. Sources of Styles Author (developer) Styles • Inline Styles - As inline attribute “style” inside HTML tags <div style=“font-weight: bold;”>I am bold</div> • Embedded Styles - As embedded style tag with in HTML document. <html> <head> <title>Welcome to Vendio!</title> <style> .footer { width:90%; } </style> </html> • Linked Styles - Inside separate files with .css extension <link rel="stylesheet" href=“external.css" type="text/css" />
  • 8. Sources of Styles(contd.) • User Style sheets This file contains the user created styles . [firefox profile folder]/ chrome/userContent-example.css is the current user’s style sheet file for the firefox. • Browser default style sheet This file contains default styles for all users of a browser [firefox folder]/res/html.css is the default style sheet file for the firefox.
  • 9. Cascade The CSS cascade assigns a weight to each style rule. When several rules apply, the one with the greatest weight takes precedence. Order of preference for various styles: – Default browser style sheet (weakest) – User style sheet – Author style sheet – Author embedded styles – Author inline styles (strongest)
  • 10. CSS Selectors • ID based ( #) HTML <div id=“content”> Text </div> CSS #content { width: 200px; } ID selectors should be used with single elements.
  • 11. Class based selector • Class (.) HTML <div class=“big”> Text </div> <div> CSS .content { width: 200px; } <span class=“big”>some text </span> </div> Class based styles can be used by multiple HTML elements.
  • 12. Tag based selectors • Tag (Tag name) HTML CSS <div> DIV { Text width: 200px; </div> } <div> SPAN { <span>some text </span> font-size:130%; </div> } <span>some other text </span>
  • 13. Grouping • Multiple selectors can be grouped in a single style declaration by using , . H1, P , .main { font-weight:bold; }
  • 14. Descendant selectors Descendant selectors are used to select elements that are descendants (not necessarily children) of another element in the document tree. CSS DIV.abc P { font-weight:bold; } HTML <div class=“abc”> <div> <P> Hello there! </p> </div> </div>
  • 15. Child selectors A child selector is used to select an element that is a direct child of another element (parent). Child selectors will not select all descendants, only direct children. CSS DIV.abc > P { font-weight:bold; } HTML <div > <div class=“abc”> <P> Hello there! </p> </div> </div>
  • 16. Universal selectors Universal selectors are used to select any element. * { color: blue; }
  • 17. Adjacent sibling selectors Adjacent sibling selectors will select the sibling immediately following an element. DIV.abc + P { font-weight: bold; } will work for <div> <div class=“abc”>Message</div> <P>Hello there!</p> </div>
  • 18. Attribute selectors Attribute selectors selects elements based upon the attributes present in the HTML Tags and their value. IMG[src="small.gif"] { border: 1px solid #000; } will work for <img src=“small.gif” />
  • 19. CSS Pseudo-classes selector:pseudo-class { property: value } :link :visited :hover :active } Link (A tag) related pseudo classes :after :before :first-child :focus :first-letter :first-line :lang
  • 20. CSS Values • Words: text-align:center;. • Numerical values: Numerical values are usually followed by a unit type. font-size:12px; 12 is the numerical value and px is the unit type pixels. – Absolute Values – in, pc, px, cm, mm, pt – Relative Values – em, ex, % • Color values: color:#336699 or color#369.
  • 21. Categories of CSS properties • Positioning and layout handling related. • Background related properties. • Font and text related • Links related. • Lists related. • Table related.
  • 23. The Display Property • Block Level elements, such as DIVs, paragraphs, headings, and lists, sit one above another when displayed in the browser. HTML <body> <div id=“div1”></div> <div id=“div2”></div> <div id=“div3”></div> </body> CSS #div1 { width:300px;background:yellow;} #div1 { width:300px;background:blue;} #div1 { width:300px;background:orange;}
  • 24. Inline Elements • Inline elements such as a, span, and img, sit side by side when they are displayed in the browser and only appear on a new line if there is insufficient room on the previous one. <div id="row1" > <span class="norm">This is small text and </span> <span class="big">this is big</ span> <span class="italicText"> I am Italic</span> </div> .norm { color:red; } .big { color:blue; font-weight:bold; } .italicText { color:green; font-style:italic; } #row1 { padding:10px; border:solid 1px #000; }
  • 26. Visibility Visible : The element is visible (default). Hidden : The element is invisible (but still takes up space) .big { visibility:hidden; }
  • 27. z-index The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order. only works on positioned elements (position:absolute, position:relative, or position:fixed).
  • 28. Default page flow Always think of web page as 3D arrangement of different layers.
  • 29. Floating float:left, right, none; A floated box is laid out according to the normal flow, then taken out of the flow and shifted to the left or right as far as possible. IMG { left; } float:
  • 30. Floating multiple elements Floated boxes will move to the left or right until their outer edge touches the containing block edge or the outer edge of another float. <ul> <li>Home</li> <li>Products</li> <li>Services</li> <li>Contact Us</li> </ul> After applying LI { float:left; }
  • 31. Clearing Floats Clear:both ; Or <style type="text/css"> .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-block;} /* for IE/Mac */ </style> <!--[if IE]><style type="text/css"> .clearfix { zoom: 1; display: block; } </style> <![endif]-->
  • 32. Positioning - static position:static; (Default option) the element occurs in the normal flow (ignores any top, bottom, left, right, or z-index declarations)
  • 33. Positioning - relative position:relative; Generates a relatively positioned element, positioned relative to its normal position, use bottom, right, top and left property to place element. Default flow of other elements don’t change.
  • 34. Positioning - absolute position:relative; Generates an absolutely positioned element, positioned relative to the first parent element that has a position other than static (if none is found, relative to document’s BODY). use bottom, right, top and left property to place element
  • 35. Positioning - fixed position:relative; Generates an absolutely positioned element, positioned relative to the browser window and don’t change even after page scroll. use bottom, right, top and left property to place element
  • 36. Inheritance • Styles that relate to text and appearance are inherited by the descendant elements. • Styles that relate to the appearance of boxes created by styling DIVs, paragraphs, and other elements, such as borders, padding, margins are not inherited.
  • 37.
  翻译: