SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
Cascading Style Sheet

  www.eshikshak.co.in
Introduction to CSS
• CSS stands Cascading Style Sheets CSS
• It handles the look and feel part of a web page, like
   –   you can control the color of the text
   –   the style of fonts
   –   the spacing between paragraphs
   –   what background images or colors are used, as well as a
       variety of other effects.
• CSS is easy to learn and understand but it provides
  powerful control over the presentation of an HTML
  document. Most commonly, CSS is combined with the
  markup languages HTML or XHTML.

                          www.eshikshak.co.in
Advantages of CSS
•   CSS saves time - You can write CSS once and then reuse same sheet in multiple
    HTML pages. You can define a style for each HTML element and apply it to as
    many Web pages as you want.
•   Pages load faster - If you are using CSS, you do not need to write HTML tag
    attributes every time. Just write one CSS rule of a tag and apply to all the
    occurrences of that tag. So less code means faster download times.
•   Easy maintenance - To make a global change, simply change the style, and all
    elements in all the web pages will be updated automatically.
•   Superior styles to HTML - CSS has a much wider array of attributes than HTML
    so you can give far better look to your HTML page in comparison of HTML
    attributes.
•   Multiple Device Compatibility - Style sheets allow content to be optimized for
    more than one type of device. By using the same HTML document, different
    versions of a website can be presented for handheld devices such as PDAs and cell
    phones or for printing.
•   Global web standards - Now HTML attributes are being deprecated and it is being
    recommended to use CSS. So its a good idea to start using CSS in all the HTML
    pages to make them compatible to future browsers.


                                   www.eshikshak.co.in
Who Creates and Maintains
               CSS?
• CSS is created and maintained through a group of
  people within the W3C called the CSS Working
  Group.
• The CSS Working Group creates documents
  called specifications.
• When a specification has been discussed and
  officially ratified by W3C members, it becomes a
  recommendation.
• NOTE: The World Wide Web Consortium, or W3C is a group that makes
  recommendations about how the Internet works and how it should evolve.


                              www.eshikshak.co.in
Syntax
• A CSS comprises of style rules that are interpreted by
  the browser and then applied to the corresponding
  elements in your document. A style rule is made of
  three parts:
   – Selector: A selector is an HTML tag at which style will be
     applied. This could be any tag like <h1> or <table> etc.
   – Property: A property is a type of attribute of HTML tag.
     Put simply, all the HTML attributes are converted into CSS
     properties. They could be color or border etc.
   – Value: Values are assigned to properties. For example
     color property can have value either red or #F1F1F1 etc.


                          www.eshikshak.co.in
Syntax
• You can put CSS Style Rule Syntax as follows


    selector                                       table
     {                                             {
          property: value;                            border :1px solid
     }                                             #C00; }




                             www.eshikshak.co.in
The Type Selectors

h1
{
  color: #36CFFF;
}


    to give a color to all level 1 headings :




                    www.eshikshak.co.in
The Descendant Selectors

       ul em {
         color: #000000;
       }


style rule will apply to <em> element only when it lies inside <ul>
tag.




                           www.eshikshak.co.in
The Class Selectors
• Define style rules based on the class attribute
  of the elements.
• All the elements having that class will be
  formatted according to the defined rule.

                    <p class="center bold">
.black {
                    This para will be styled by the classes
  color: #000000;
                    center and bold.
}
                    </p>

                    www.eshikshak.co.in
The ID Selectors
• Define style rules based on the id attribute of
  the elements.
• All the elements having that id will be
  formatted according to the defined rule.
 #black
 {
   color: #000000;
 }




                          www.eshikshak.co.in
The ID Selectors
• This rule renders the content in black for every
  element with id attribute set to black in our
  document. You can make it a bit more
  particular. For example:
              h1#black {
                color: #000000;
              }




                        www.eshikshak.co.in
The Attribute Selectors
• Apply styles to HTML elements with particular attributes.
• The style rule below will match all input elements that has a
  type attribute with a value of text.
• The advantage to this method is that the <input type="submit"
  /> element is unaffected, and the color applied only to the
  desired text fields.

   input[type="text"]
   {
     color: #000000;
   }

                          www.eshikshak.co.in
• There are following rules applied to attribute selector.
   – p[lang] - Selects all paragraph elements with a lang
     attribute.
   – p[lang="fr"] - Selects all paragraph elements whose lang
     attribute has a value of exactly "fr".
   – p[lang~="fr"] - Selects all paragraph elements whose lang
     attribute contains the word "fr".
   – p[lang|="en"] - Selects all paragraph elements whose lang
     attribute contains values that are exactly "en", or begin with
     "en-".


                            www.eshikshak.co.in
Multiple Style Rules
• You may need to define multiple style rules for a single
  element. You can define these rules to combine multiple
  properties and corresponding values into a single block as
  defined in the following example

                   h1
                   {
                   color: #36C;
                   font-weight: normal;
                   letter-spacing: .4em;
                   margin-bottom: 1em;
                   text-transform: lowercase;
                   }
                          www.eshikshak.co.in

Contenu connexe

Tendances

1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
apnwebdev
 
CSS - Text Properties
CSS - Text PropertiesCSS - Text Properties
CSS - Text Properties
hstryk
 

Tendances (20)

Css ppt
Css pptCss ppt
Css ppt
 
css.ppt
css.pptcss.ppt
css.ppt
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
 
Css3
Css3Css3
Css3
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
CSS selectors
CSS selectorsCSS selectors
CSS selectors
 
What is CSS?
What is CSS?What is CSS?
What is CSS?
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Java script
Java scriptJava script
Java script
 
Learn html Basics
Learn html BasicsLearn html Basics
Learn html Basics
 
Html
HtmlHtml
Html
 
Introduction to XHTML
Introduction to XHTMLIntroduction to XHTML
Introduction to XHTML
 
CSS - Text Properties
CSS - Text PropertiesCSS - Text Properties
CSS - Text Properties
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
Basic html
Basic htmlBasic html
Basic html
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Html and css
Html and cssHtml and css
Html and css
 

En vedette

Introduction to computer_and_its_structure
Introduction to computer_and_its_structureIntroduction to computer_and_its_structure
Introduction to computer_and_its_structure
eShikshak
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
eShikshak
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppt
eShikshak
 
Language processors
Language processorsLanguage processors
Language processors
eShikshak
 

En vedette (15)

Lecture 11 css_inculsion
Lecture 11 css_inculsionLecture 11 css_inculsion
Lecture 11 css_inculsion
 
Lecture 12 css_fonts
Lecture 12 css_fontsLecture 12 css_fonts
Lecture 12 css_fonts
 
Introduction to computer_and_its_structure
Introduction to computer_and_its_structureIntroduction to computer_and_its_structure
Introduction to computer_and_its_structure
 
Program development cyle
Program development cyleProgram development cyle
Program development cyle
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
 
Computer programming programming_langugages
Computer programming programming_langugagesComputer programming programming_langugages
Computer programming programming_langugages
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloud
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computing
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppt
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computing
 
Introduction to multimedia
Introduction to multimediaIntroduction to multimedia
Introduction to multimedia
 
Html forms
Html formsHtml forms
Html forms
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computing
 
Language processors
Language processorsLanguage processors
Language processors
 

Similaire à Introduction to css

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
 
Css tutorial by viveksingh698@gmail.com
Css tutorial by viveksingh698@gmail.comCss tutorial by viveksingh698@gmail.com
Css tutorial by viveksingh698@gmail.com
vivek698
 
Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
Jeff Byrnes
 

Similaire à Introduction to css (20)

Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)
 
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
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
 
DHTML
DHTMLDHTML
DHTML
 
Css
CssCss
Css
 
Csstutorial
CsstutorialCsstutorial
Csstutorial
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Css - Tutorial
Css - TutorialCss - Tutorial
Css - Tutorial
 
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
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
 
CSS.pptx
CSS.pptxCSS.pptx
CSS.pptx
 
Css tutorial by viveksingh698@gmail.com
Css tutorial by viveksingh698@gmail.comCss tutorial by viveksingh698@gmail.com
Css tutorial by viveksingh698@gmail.com
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Css tutorial
Css tutorial Css tutorial
Css tutorial
 
Week11 Lecture: CSS
Week11 Lecture: CSSWeek11 Lecture: CSS
Week11 Lecture: CSS
 
Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
 

Plus de eShikshak

Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
eShikshak
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
eShikshak
 

Plus de eShikshak (20)

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluation
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerce
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computing
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executions
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
Lecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorsLecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operators
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppt
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppt
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
Lecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.pptLecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.ppt
 
Lecture13 control statementswitch.ppt
Lecture13 control statementswitch.pptLecture13 control statementswitch.ppt
Lecture13 control statementswitch.ppt
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Introduction to css

  • 1. Cascading Style Sheet www.eshikshak.co.in
  • 2. Introduction to CSS • CSS stands Cascading Style Sheets CSS • It handles the look and feel part of a web page, like – you can control the color of the text – the style of fonts – the spacing between paragraphs – what background images or colors are used, as well as a variety of other effects. • CSS is easy to learn and understand but it provides powerful control over the presentation of an HTML document. Most commonly, CSS is combined with the markup languages HTML or XHTML. www.eshikshak.co.in
  • 3. Advantages of CSS • CSS saves time - You can write CSS once and then reuse same sheet in multiple HTML pages. You can define a style for each HTML element and apply it to as many Web pages as you want. • Pages load faster - If you are using CSS, you do not need to write HTML tag attributes every time. Just write one CSS rule of a tag and apply to all the occurrences of that tag. So less code means faster download times. • Easy maintenance - To make a global change, simply change the style, and all elements in all the web pages will be updated automatically. • Superior styles to HTML - CSS has a much wider array of attributes than HTML so you can give far better look to your HTML page in comparison of HTML attributes. • Multiple Device Compatibility - Style sheets allow content to be optimized for more than one type of device. By using the same HTML document, different versions of a website can be presented for handheld devices such as PDAs and cell phones or for printing. • Global web standards - Now HTML attributes are being deprecated and it is being recommended to use CSS. So its a good idea to start using CSS in all the HTML pages to make them compatible to future browsers. www.eshikshak.co.in
  • 4. Who Creates and Maintains CSS? • CSS is created and maintained through a group of people within the W3C called the CSS Working Group. • The CSS Working Group creates documents called specifications. • When a specification has been discussed and officially ratified by W3C members, it becomes a recommendation. • NOTE: The World Wide Web Consortium, or W3C is a group that makes recommendations about how the Internet works and how it should evolve. www.eshikshak.co.in
  • 5. Syntax • A CSS comprises of style rules that are interpreted by the browser and then applied to the corresponding elements in your document. A style rule is made of three parts: – Selector: A selector is an HTML tag at which style will be applied. This could be any tag like <h1> or <table> etc. – Property: A property is a type of attribute of HTML tag. Put simply, all the HTML attributes are converted into CSS properties. They could be color or border etc. – Value: Values are assigned to properties. For example color property can have value either red or #F1F1F1 etc. www.eshikshak.co.in
  • 6. Syntax • You can put CSS Style Rule Syntax as follows selector table { { property: value; border :1px solid } #C00; } www.eshikshak.co.in
  • 7. The Type Selectors h1 { color: #36CFFF; } to give a color to all level 1 headings : www.eshikshak.co.in
  • 8. The Descendant Selectors ul em { color: #000000; } style rule will apply to <em> element only when it lies inside <ul> tag. www.eshikshak.co.in
  • 9. The Class Selectors • Define style rules based on the class attribute of the elements. • All the elements having that class will be formatted according to the defined rule. <p class="center bold"> .black { This para will be styled by the classes color: #000000; center and bold. } </p> www.eshikshak.co.in
  • 10. The ID Selectors • Define style rules based on the id attribute of the elements. • All the elements having that id will be formatted according to the defined rule. #black { color: #000000; } www.eshikshak.co.in
  • 11. The ID Selectors • This rule renders the content in black for every element with id attribute set to black in our document. You can make it a bit more particular. For example: h1#black { color: #000000; } www.eshikshak.co.in
  • 12. The Attribute Selectors • Apply styles to HTML elements with particular attributes. • The style rule below will match all input elements that has a type attribute with a value of text. • The advantage to this method is that the <input type="submit" /> element is unaffected, and the color applied only to the desired text fields. input[type="text"] { color: #000000; } www.eshikshak.co.in
  • 13. • There are following rules applied to attribute selector. – p[lang] - Selects all paragraph elements with a lang attribute. – p[lang="fr"] - Selects all paragraph elements whose lang attribute has a value of exactly "fr". – p[lang~="fr"] - Selects all paragraph elements whose lang attribute contains the word "fr". – p[lang|="en"] - Selects all paragraph elements whose lang attribute contains values that are exactly "en", or begin with "en-". www.eshikshak.co.in
  • 14. Multiple Style Rules • You may need to define multiple style rules for a single element. You can define these rules to combine multiple properties and corresponding values into a single block as defined in the following example h1 { color: #36C; font-weight: normal; letter-spacing: .4em; margin-bottom: 1em; text-transform: lowercase; } www.eshikshak.co.in