SlideShare a Scribd company logo
1 of 18
CSS
  Chained classes




Julien BRAURE – julien@jazar.co.uk
CSS – Chained classes




     •What is CSS ?

     •Quick overview

     •Chained classes

     •Examples

     •Conclusion

     •Questions and maybe answers




CSS – Chained classes
What is CSS ?


   •CSS : Cascading Style Sheet

   •Separate Content         and     Presentation

                  HTML                      CSS
                 <html>        +      body {            =
                  <body>                color: #fff;
                                      }




   •Save server load
             Page1 ?
                                     HTML
                                     Page              CSS
                                       1



              Page 2 ?
                                     HTML
                                     Page
                                       2


   •Reduce maintenance time

   Change in the design ? only update the CSS file



CSS – Chained classes
Quick overview




  HTML                                           CSS

  <markup class=“class1” id=“this-one” />        markup.class1#this-one {
                                                           /* here goes the declarations */
                                                           color: #f00;
                                                           border: 1px solid #000;
                                                 }


                            classes are prefix with a dot (.)
                            id is prefix with a sharp (#)




CSS – Chained classes
Chained classes (HTML side)


    •In HTML the class attribute, may have multiple classes, space separated
    <p class=“class1 class2 ... classN”>


  HTML                                          CSS

  <p class=“class1”>                            p.class1 {
      Lorem ipsum dolor sit amet.                            color: red;
  </p>                                          }

  <p class=“class2”>                            p.class2 {
      Lorem ipsum dolor sit amet.                            font-weight: bold;
  </p>                                          }

  <p class=“class1 class2”>
      Lorem ipsum dolor sit amet.
  </p>


                        CSS declarations are merging ...
                        This paragraph is red AND bold




CSS – Chained classes
Chained classes (CSS side)


    •In HTML the class attribute, may have multiple classes, space separated
    <p class=“class1 class2 ... classN”>


  HTML                                              CSS

  <p class=“class1”>                                p.class1 {
      Lorem ipsum dolor sit amet.                                 color: red;
  </p>                                              }

  <p class=“class2”>                                p.class2 {
      Lorem ipsum dolor sit amet.                                 font-weight: bold;
  </p>                                              }

  <p class=“class1 class2”>                         p.class1.class2 {
      Lorem ipsum dolor sit amet.                                 text-decoration: underline;
  </p>                                              }


  CSS declarations are merging ...                  This declarations only applies to markup
  This paragraph is red, bold AND underlined        with class1 AND class2



                                    Chained classes :
                                    •HTML : space separated
                                    •CSS : concatenated
CSS – Chained classes
Chained classes (CSS side)


    •In HTML the class attribute, may have multiple classes, space separated
    <p class=“class1 class2 ... classN”>


  HTML                                     CSS

  <p class=“class1”>                       p.class1 {                         overwrites
      Lorem ipsum dolor sit amet.                        color: red;
  </p>                                     }

  <p class=“class2”>                       p.class2 {
      Lorem ipsum dolor sit amet.                        font-weight: bold;
  </p>                                     }

  <p class=“class1 class2”>                p.class1.class2 {
      Lorem ipsum dolor sit amet.                        text-decoration: underline;
  </p>                                                   color: green;
                                           }




CSS – Chained classes
Chained classes – Example 1


    Messages: success, error, info




CSS – Chained classes
Chained classes - Example

    HTML                                               CSS


                                                     p.message {
                                                       border: 2px solid;
                                      Common           padding: 16px 8px 16px 48px;
                                      declarations     background-repeat: no-repeat;
                                                       background-position: 8px center;
                                                     }




                                                     p.message.success {
    <p class=“message success”>                        border-color: green;
        Great !                                        color: green;
        It has been done.                              background-image: url(img/message.success.gif);
    </p>                                             }

                                                     p.message.error {
    <p class=“message error”>                          border-color: red;
        Bad luck !                                     color: red;
        Some error happens.                            background-image: url(img/message.error.gif);
    </p>                                             }

                                                     p.message.info {
    <p class=“message info”>                           border-color: blue;
        Some important information.                    color: blue;
    </p>                                               background-image: url(img/message.info.gif);
                                                     }

CSS – Chained classes
Chained classes – Example 2 - Site wide organisation




     •Insurance website
          •Static contents
               •Faq’s
               •Legal informations
               •Some other contents
          •Dynamic sections
               •Cars insurance
               •Houses insurance



     •Design
         •Static:
              •Grey
         •Dynamic:
              •Car section: red
              •House section: blue


CSS – Chained classes
Chained classes – Example 2 - Site wide organisation


     •Basic layout:




                        <div id=“header”>
                        </div>

                        <div class=“page”>
                            <h1>title of the page</h1>

                            <p>some content</p>
                            <p>some content</p>
                            <p>some content</p>
                        </div>

                        <div id=“footer”>
                        </div>



CSS – Chained classes
Chained classes – Example 2 - Site wide organisation

     •Sample sitemap
                                                                .page

      .dynamic                    .static
                                     .faq
        .car
                                            #q1    #q2
          #step1        #step2
                                                          ...

                                     .legal

        .house                              #tos

          #step1        #step2


                                       #contact




CSS – Chained classes
Chained classes – Example 2 - Site wide organisation

     •Sample sitemap
                                                                   .page

      .dynamic                    .static

                                     .faq
        .car
               <div class=“page dynamic house” id=“step2”>
                                         #q1       #q2
          #step1
               </div>#step2
                                                             ...

                                     .legal

        .house                              #tos

          #step1        #step2


                                       #contact




CSS – Chained classes
Chained classes – Example 2 - Site wide organisation

     •Sample sitemap
                                                                     .page

      .dynamic                       .static

                                        .faq
        .car
                                               #q1    #q2
          #step1        #step2
                                                               ...

                                        .legal

        .house                                 #tos

          #step1        #step2


                                          #contact
                                 <div class=“page static legal” id=“tos”>
                                 </div>


CSS – Chained classes
Chained classes – Example 2 - Site wide organisation

                                           CSS

                                         .page h1 {
                          Common            font-size: 16px;
                          declarations   }


                                         .page.static h1 {
                                            background-color: grey;
                                         }


                                         .page.dynamic.car h1 {
                                            background-color: red;
                                         }


                                         .page.dynamic.house h1 {
                                            background-color: blue;
                                         }




CSS – Chained classes
Chained classes – Example 2 - Site wide organisation


    Customized messages on car pages ?




    .page.dynamic.car .message.success {
          background-image: url(img/dynamic/car/message.success.gif);
    }




CSS – Chained classes
Conclusion


     •Real separation between content and presentation


     •Ability to deploy rapidly alternative design, for Christmas for example



    To keep in mind

     •In my HTML:       what I want to say
     •In my CSS:        how I want to render it

     •Avoid presentation related classes in HTML
         Eg: bold, small, rounded, ...




CSS – Chained classes
Questions ?




                        Any questions ?




CSS – Chained classes

More Related Content

Similar to CSS - chained classes

Html Css
Html CssHtml Css
Html Csspumas26
 
jQuery and Ruby Web Frameworks
jQuery and Ruby Web FrameworksjQuery and Ruby Web Frameworks
jQuery and Ruby Web FrameworksYehuda Katz
 
Haml And Sass: Put your markup on a diet
Haml And Sass: Put your markup on a dietHaml And Sass: Put your markup on a diet
Haml And Sass: Put your markup on a dietdavidsidlinger
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test51 lecture
 
Standardizing the Web: A Look into the Why of Web Standards
Standardizing the Web: A Look into the Why of Web StandardsStandardizing the Web: A Look into the Why of Web Standards
Standardizing the Web: A Look into the Why of Web StandardsTim Wright
 
What I discovered about layout vis CSS Grid
What I discovered about layout vis CSS GridWhat I discovered about layout vis CSS Grid
What I discovered about layout vis CSS GridRachel Andrew
 
Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2sleguiza
 
Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009Bastian Feder
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsKaelig Deloumeau-Prigent
 
Google Developers Experts Summit 2017 - CSS Layout
Google Developers Experts Summit 2017 - CSS Layout Google Developers Experts Summit 2017 - CSS Layout
Google Developers Experts Summit 2017 - CSS Layout Rachel Andrew
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Railsdosire
 
An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)Ardee Aram
 
W2Tags Is Haml In Erb
W2Tags Is Haml In ErbW2Tags Is Haml In Erb
W2Tags Is Haml In Erbwidi harsojo
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperWynn Netherland
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESSjsmith92
 
3 coding101 fewd_lesson3_your_first_website 20210105
3 coding101 fewd_lesson3_your_first_website 202101053 coding101 fewd_lesson3_your_first_website 20210105
3 coding101 fewd_lesson3_your_first_website 20210105John Picasso
 

Similar to CSS - chained classes (20)

Html Css
Html CssHtml Css
Html Css
 
jQuery and Ruby Web Frameworks
jQuery and Ruby Web FrameworksjQuery and Ruby Web Frameworks
jQuery and Ruby Web Frameworks
 
Haml And Sass: Put your markup on a diet
Haml And Sass: Put your markup on a dietHaml And Sass: Put your markup on a diet
Haml And Sass: Put your markup on a diet
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test
 
Standardizing the Web: A Look into the Why of Web Standards
Standardizing the Web: A Look into the Why of Web StandardsStandardizing the Web: A Look into the Why of Web Standards
Standardizing the Web: A Look into the Why of Web Standards
 
What I discovered about layout vis CSS Grid
What I discovered about layout vis CSS GridWhat I discovered about layout vis CSS Grid
What I discovered about layout vis CSS Grid
 
Practical Groovy DSL
Practical Groovy DSLPractical Groovy DSL
Practical Groovy DSL
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2
 
Haml, Sass & Compass
Haml, Sass & CompassHaml, Sass & Compass
Haml, Sass & Compass
 
Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
Google Developers Experts Summit 2017 - CSS Layout
Google Developers Experts Summit 2017 - CSS Layout Google Developers Experts Summit 2017 - CSS Layout
Google Developers Experts Summit 2017 - CSS Layout
 
The Future of CSS
The Future of CSSThe Future of CSS
The Future of CSS
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)
 
W2Tags Is Haml In Erb
W2Tags Is Haml In ErbW2Tags Is Haml In Erb
W2Tags Is Haml In Erb
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESS
 
3 coding101 fewd_lesson3_your_first_website 20210105
3 coding101 fewd_lesson3_your_first_website 202101053 coding101 fewd_lesson3_your_first_website 20210105
3 coding101 fewd_lesson3_your_first_website 20210105
 

Recently uploaded

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Recently uploaded (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

CSS - chained classes

  • 1. CSS Chained classes Julien BRAURE – julien@jazar.co.uk
  • 2. CSS – Chained classes •What is CSS ? •Quick overview •Chained classes •Examples •Conclusion •Questions and maybe answers CSS – Chained classes
  • 3. What is CSS ? •CSS : Cascading Style Sheet •Separate Content and Presentation HTML CSS <html> + body { = <body> color: #fff; } •Save server load Page1 ? HTML Page CSS 1 Page 2 ? HTML Page 2 •Reduce maintenance time Change in the design ? only update the CSS file CSS – Chained classes
  • 4. Quick overview HTML CSS <markup class=“class1” id=“this-one” /> markup.class1#this-one { /* here goes the declarations */ color: #f00; border: 1px solid #000; } classes are prefix with a dot (.) id is prefix with a sharp (#) CSS – Chained classes
  • 5. Chained classes (HTML side) •In HTML the class attribute, may have multiple classes, space separated <p class=“class1 class2 ... classN”> HTML CSS <p class=“class1”> p.class1 { Lorem ipsum dolor sit amet. color: red; </p> } <p class=“class2”> p.class2 { Lorem ipsum dolor sit amet. font-weight: bold; </p> } <p class=“class1 class2”> Lorem ipsum dolor sit amet. </p> CSS declarations are merging ... This paragraph is red AND bold CSS – Chained classes
  • 6. Chained classes (CSS side) •In HTML the class attribute, may have multiple classes, space separated <p class=“class1 class2 ... classN”> HTML CSS <p class=“class1”> p.class1 { Lorem ipsum dolor sit amet. color: red; </p> } <p class=“class2”> p.class2 { Lorem ipsum dolor sit amet. font-weight: bold; </p> } <p class=“class1 class2”> p.class1.class2 { Lorem ipsum dolor sit amet. text-decoration: underline; </p> } CSS declarations are merging ... This declarations only applies to markup This paragraph is red, bold AND underlined with class1 AND class2 Chained classes : •HTML : space separated •CSS : concatenated CSS – Chained classes
  • 7. Chained classes (CSS side) •In HTML the class attribute, may have multiple classes, space separated <p class=“class1 class2 ... classN”> HTML CSS <p class=“class1”> p.class1 { overwrites Lorem ipsum dolor sit amet. color: red; </p> } <p class=“class2”> p.class2 { Lorem ipsum dolor sit amet. font-weight: bold; </p> } <p class=“class1 class2”> p.class1.class2 { Lorem ipsum dolor sit amet. text-decoration: underline; </p> color: green; } CSS – Chained classes
  • 8. Chained classes – Example 1 Messages: success, error, info CSS – Chained classes
  • 9. Chained classes - Example HTML CSS p.message { border: 2px solid; Common padding: 16px 8px 16px 48px; declarations background-repeat: no-repeat; background-position: 8px center; } p.message.success { <p class=“message success”> border-color: green; Great ! color: green; It has been done. background-image: url(img/message.success.gif); </p> } p.message.error { <p class=“message error”> border-color: red; Bad luck ! color: red; Some error happens. background-image: url(img/message.error.gif); </p> } p.message.info { <p class=“message info”> border-color: blue; Some important information. color: blue; </p> background-image: url(img/message.info.gif); } CSS – Chained classes
  • 10. Chained classes – Example 2 - Site wide organisation •Insurance website •Static contents •Faq’s •Legal informations •Some other contents •Dynamic sections •Cars insurance •Houses insurance •Design •Static: •Grey •Dynamic: •Car section: red •House section: blue CSS – Chained classes
  • 11. Chained classes – Example 2 - Site wide organisation •Basic layout: <div id=“header”> </div> <div class=“page”> <h1>title of the page</h1> <p>some content</p> <p>some content</p> <p>some content</p> </div> <div id=“footer”> </div> CSS – Chained classes
  • 12. Chained classes – Example 2 - Site wide organisation •Sample sitemap .page .dynamic .static .faq .car #q1 #q2 #step1 #step2 ... .legal .house #tos #step1 #step2 #contact CSS – Chained classes
  • 13. Chained classes – Example 2 - Site wide organisation •Sample sitemap .page .dynamic .static .faq .car <div class=“page dynamic house” id=“step2”> #q1 #q2 #step1 </div>#step2 ... .legal .house #tos #step1 #step2 #contact CSS – Chained classes
  • 14. Chained classes – Example 2 - Site wide organisation •Sample sitemap .page .dynamic .static .faq .car #q1 #q2 #step1 #step2 ... .legal .house #tos #step1 #step2 #contact <div class=“page static legal” id=“tos”> </div> CSS – Chained classes
  • 15. Chained classes – Example 2 - Site wide organisation CSS .page h1 { Common font-size: 16px; declarations } .page.static h1 { background-color: grey; } .page.dynamic.car h1 { background-color: red; } .page.dynamic.house h1 { background-color: blue; } CSS – Chained classes
  • 16. Chained classes – Example 2 - Site wide organisation Customized messages on car pages ? .page.dynamic.car .message.success { background-image: url(img/dynamic/car/message.success.gif); } CSS – Chained classes
  • 17. Conclusion •Real separation between content and presentation •Ability to deploy rapidly alternative design, for Christmas for example To keep in mind •In my HTML: what I want to say •In my CSS: how I want to render it •Avoid presentation related classes in HTML Eg: bold, small, rounded, ... CSS – Chained classes
  • 18. Questions ? Any questions ? CSS – Chained classes