SlideShare uma empresa Scribd logo
1 de 25
Introduction to CSS
     By Amit Tyagi
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.
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.
CSS Selectors
• ID based ( #)
      HTML                              CSS
<div id=“content”>               #content {
  Text                                 width: 200px;
</div>                           }



ID selectors should be used with single elements.
Class based selector
• Class (.)
       HTML                                   CSS
<div class=“big”>                     .big{
   Text                                       width: 200px;
</div>                                }
<div>
   <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.
    HTML                            CSS
<div class=“abc”>            DIV.abc P {
  <div>                        font-weight:bold;
    <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.
     HTML                              CSS
<div >                          DIV.abc > P {
  <div class=“abc”>               font-weight:bold;
    <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           } Link (A tag) related pseudo classes
:hover
:active

: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 or
  rgb(255, 255, 255).
Categories of CSS properties
•   Positioning and layout handling related.
•   Background related properties.
•   Font and text related
•   Links related.
•   Lists related.
•   Table related.
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 Specificity
Rule 1. CSS File >> Embedded >> Inline

Rule 2. TAG >> class >> ID
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

Mais conteúdo relacionado

Mais procurados (20)

Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
 
Html Ppt
Html PptHtml Ppt
Html Ppt
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
CSS
CSSCSS
CSS
 
HTML CSS Basics
HTML CSS BasicsHTML CSS Basics
HTML CSS Basics
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
HTML (Web) basics for a beginner
HTML (Web) basics for a beginnerHTML (Web) basics for a beginner
HTML (Web) basics for a beginner
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
Tags in html
Tags in htmlTags in html
Tags in html
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
 
html-table
html-tablehtml-table
html-table
 
Javascript
JavascriptJavascript
Javascript
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
 
Css box-model
Css box-modelCss box-model
Css box-model
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
 

Destaque

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
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet pptabhilashagupta
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksAmit Tyagi
 
HTML presentation for beginners
HTML presentation for beginnersHTML presentation for beginners
HTML presentation for beginnersjeroenvdmeer
 

Destaque (8)

CSS ppt
CSS pptCSS ppt
CSS ppt
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
Cookie and session
Cookie and sessionCookie and session
Cookie and session
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
HTML presentation for beginners
HTML presentation for beginnersHTML presentation for beginners
HTML presentation for beginners
 
Cookies!
Cookies!Cookies!
Cookies!
 

Semelhante a Introduction to CSS

Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Likitha47
 
howcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptxhowcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptxRavneetSingh343801
 
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
 
2 introduction css
2 introduction css2 introduction css
2 introduction cssJalpesh Vasa
 
Internet tech &amp; web prog. p4,5
Internet tech &amp; web prog.  p4,5Internet tech &amp; web prog.  p4,5
Internet tech &amp; web prog. p4,5Taymoor Nazmy
 
Css basics
Css basicsCss basics
Css basicsASIT
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Erin M. Kidwell
 
4. Web Technology CSS Basics-1
4. Web Technology CSS Basics-14. Web Technology CSS Basics-1
4. Web Technology CSS Basics-1Jyoti Yadav
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxTanu524249
 
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 layoutCK Yang
 
Thinkful - Frontend Crash Course - Intro to HTML/CSS
Thinkful - Frontend Crash Course - Intro to HTML/CSSThinkful - Frontend Crash Course - Intro to HTML/CSS
Thinkful - Frontend Crash Course - Intro to HTML/CSSTJ Stalcup
 

Semelhante a Introduction to CSS (20)

css v1 guru
css v1 gurucss v1 guru
css v1 guru
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01
 
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...
 
2 introduction css
2 introduction css2 introduction css
2 introduction css
 
Web
WebWeb
Web
 
Artdm171 Week5 Css
Artdm171 Week5 CssArtdm171 Week5 Css
Artdm171 Week5 Css
 
Internet tech &amp; web prog. p4,5
Internet tech &amp; web prog.  p4,5Internet tech &amp; web prog.  p4,5
Internet tech &amp; web prog. p4,5
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
 
Web Development - Lecture 5
Web Development - Lecture 5Web Development - Lecture 5
Web Development - Lecture 5
 
Css basics
Css basicsCss basics
Css basics
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
 
Css ms megha
Css ms meghaCss ms megha
Css ms megha
 
Css
CssCss
Css
 
4. Web Technology CSS Basics-1
4. Web Technology CSS Basics-14. Web Technology CSS Basics-1
4. Web Technology CSS Basics-1
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
Web 102 INtro to CSS
Web 102  INtro to CSSWeb 102  INtro to CSS
Web 102 INtro to CSS
 
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
 
Thinkful - Frontend Crash Course - Intro to HTML/CSS
Thinkful - Frontend Crash Course - Intro to HTML/CSSThinkful - Frontend Crash Course - Intro to HTML/CSS
Thinkful - Frontend Crash Course - Intro to HTML/CSS
 
CSS
CSSCSS
CSS
 

Último

ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 

Último (20)

ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 

Introduction to CSS

  • 1. Introduction to CSS By Amit Tyagi
  • 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. 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" />
  • 7. 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.
  • 8. CSS Selectors • ID based ( #) HTML CSS <div id=“content”> #content { Text width: 200px; </div> } ID selectors should be used with single elements.
  • 9. Class based selector • Class (.) HTML CSS <div class=“big”> .big{ Text width: 200px; </div> } <div> <span class=“big”>some text </span> </div> Class based styles can be used by multiple HTML elements.
  • 10. 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>
  • 11. Grouping • Multiple selectors can be grouped in a single style declaration by using , . H1, P , .main { font-weight:bold; }
  • 12. Descendant selectors Descendant selectors are used to select elements that are descendants (not necessarily children) of another element in the document tree. HTML CSS <div class=“abc”> DIV.abc P { <div> font-weight:bold; <P> } Hello there! </p> </div> </div>
  • 13. 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. HTML CSS <div > DIV.abc > P { <div class=“abc”> font-weight:bold; <P> } Hello there! </p> </div> </div>
  • 14. Universal selectors Universal selectors are used to select any element. * { color: blue; }
  • 15. 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>
  • 16. 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” />
  • 17. CSS Pseudo-classes selector:pseudo-class { property: value } :link :visited } Link (A tag) related pseudo classes :hover :active :after :before :first-child :focus :first-letter :first-line :lang
  • 18. 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 or rgb(255, 255, 255).
  • 19. Categories of CSS properties • Positioning and layout handling related. • Background related properties. • Font and text related • Links related. • Lists related. • Table related.
  • 20. 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)
  • 21. CSS Specificity Rule 1. CSS File >> Embedded >> Inline Rule 2. TAG >> class >> ID
  • 22. 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.
  • 23.
  • 24.