SlideShare uma empresa Scribd logo
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

Mais conteúdo relacionado

Semelhante a CSS - chained classes

Html Css
Html CssHtml Css
Html Css
pumas26
 
this is ruby test
this is ruby testthis is ruby test
this is ruby test
51 lecture
 
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
Kaelig Deloumeau-Prigent
 
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
John Picasso
 

Semelhante a 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
 

Último

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Último (20)

Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Buy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptxBuy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptx
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 

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