SlideShare a Scribd company logo
1 of 24
An Introduction to CSS
 Selectors and Drupal
Understanding CSS selectors and
 how Drupal allows you to use
  them to style pages is a key
         Drupal skill
Audience Knowledge Quiz
How many…
 …know what CSS stands for

 …have “cut & pasted” CSS into sites

 …have written their own CSS rules from
  scratch

 …know what a CSS Selector is

 …are experts, just here to heckle
Why Should You Know This

Turn this:
Into this…
 with CSS
CSS Rule Syntax
Example:                         CSS Syntax:
CSS:                              <Selector> {
   A.menu:hover {
     color: #002b70;               <property>: <value>;
     text-decoration:   underline; <property>: <value>;
   }
                                   …
HTML:                             }
<UL>
  <LI>
     <A class=“menu” href=“foobar.html”>FooBar</A>
  </LI>
</UL>
What are Selectors
Patterns used to select the parts of a
document to apply the styles to.
The CSS3 spec define these patterns as:
  A chain of one or more sequence of simple
  selectors separated by combinators

Lets break this down…
Sequence of Simple Selectors
The most common simple selector types are:
 .<class>            select all elements with class=“<class>”
 <element>           match a specific HTML <element> (A, H2)
 #<id> match element with id=<id> attribute
 :<pseudo>           “pseudo class” selectors like :hover, :visited

These can be combined into sequences to target
specific document element like:
                               A.menu:hover
                               H1
                               #header
Note: There are a lot of other simple selectors, especially with CSS3. See:
                     http://www.w3.org/TR/css3-selectors/#selectors
What are Combinators
Combinators let you combine sequences of
simple selectors (S3) and target very specific
areas of a document.
Combinators are the most important CSS item
to understand with Drupal!
They let you target almost anything on a Drupal
page
Combinators
escendant – S3 S3…
Elements that are contained inside another
element. For example, the selector:


               IV.menu A:hover


ould define the hover style for any anchor tag
inside a div with class menu, even if there are
other tags between.
Combinators
hild – S3 > S3…
Describes elements that have a direct parent
and child relationship:

               L.menu > LI.leaf

ould target ONLY <LI class=“leaf”> elements
that were directly under a <UL class=“menu”>
element.

ibling – S3 + S3… or S3 ~ S3
Specificity (The Great Gotcha)
Complex CSS selectors will overlap with more
than one rule applying to an element.
Specificity defines how browsers should
calculate the “weight” of rules. The heavier ones
win.
Drupal tends to have LOTS of rules so chances
are your carefully crafted selector may not work.
Here’s how specificity is calculated:
       http://www.w3.org/TR/css3-selectors/#specificity
Something !Important
One trick to remember if your selector is not
specific enough is the !important property
declaration.
E.g., if these rules point to the same DIV, the text
color will be red (#id is highly specific).
Div#more_specific { color: red; }
Div.less_specific { color: green; }

If you add, !important to the properties, the color
will be green.
Div#more_specific { color: red; }
Div.less_specific { color: green !important; }
Drupal Areas
Drupal pages have a wide variety of CSS addressable
“areas” that are created by the system and themes.

•Page info
•Theme regions
•Nodes (Content type/Specific)
•Blocks (General / Specific )
•Menus (General / Specific )
•Views (General / Specific )
•Fields - Views & CCK (General / Specific )
•Form elements (General / Specific )
Page Info

 The body tag on Drupal pages will have
 several useful classes.

Front/Not-Front:           Front page or not
Logged-in/not-logged in:   User or Anonymous
Node-Type-<node-type>:     Class based on Node Type
Theme Regions
Theme Regions
Page Top:     <div id=“page-top” class=“region-page-top….
Header:       <div id=“header-group” class=“header-group…
Sidebar First: <div id=“sidebar-first” class=“region-sidebar-first…
Footer:       <div id=“footer” class=“region-footer…
Content:      <div id=“content” class=“region-content…

Example CSS
               #sidebar-first DIV.block {
                    padding-top: 15px;
               }
Nodes, Blocks, & Menus
Nodes, Blocks, & Menus
Node: <div id=“node-2” class=“node node-page full-node…
Block: <div id=“block-block-2” class=“block…
Menu: <div id=“block-system-main-menu”
             class=“block block-system block-menu…

Example CSS
   #block-block2 .content {
     background-image: url("../images/SkylarkingDef2.gif");
     background-repeat: no-repeat;
     width: 151px;
     height: 308px;;
   }
Views & View Fields
Views & View Fields

View: <div class=“view view-photo-galleries…

Field: <div class=“views-field views-field-title…


Example CSS
    .view-photo-galleries .views-field-title {
      padding-bottom: 6px;
    }
    .view-photo-galleries .views-field-title A {
      font-size: 18px;
    }
CCK Fields
CCK Fields
Field:        <div class=“field field-name-field-quest…
Field Label: <div class=“field-label…
Field Items: <div class=“field-items…
Field Item:   <div class=“field-item…

 Example CSS
     .node-field-example .field DIV.field-label {
       padding: 1em 0;
     }
     .node-field-example .field DIV.items {
       padding: 1em 0 2em 1em;
     }
Form Fields

No examples prepared, but
forms are similar to CCK /
Node fields.
Helpful Tools

FireFox with FireBug

Chrome with built in Explore Element
Questions?

This has covered a lot of complex
       concepts quickly….

More Related Content

What's hot

CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers10Clouds
 
Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development PresentationTurnToTech
 
HTML Start Up - Introduction to HTML
HTML Start Up - Introduction to HTMLHTML Start Up - Introduction to HTML
HTML Start Up - Introduction to HTMLGrayzon Gonzales, LPT
 
ASP.NET Developer Roadmap 2021
ASP.NET Developer Roadmap 2021ASP.NET Developer Roadmap 2021
ASP.NET Developer Roadmap 2021Ronak Sankhala
 
Bootstrap Part - 1
Bootstrap Part - 1Bootstrap Part - 1
Bootstrap Part - 1EPAM Systems
 
Web-Development-ppt.pptx
Web-Development-ppt.pptxWeb-Development-ppt.pptx
Web-Development-ppt.pptxEleenaJha
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by MukeshMukesh Kumar
 
HTML, CSS, JavaScript for beginners
HTML, CSS, JavaScript for beginnersHTML, CSS, JavaScript for beginners
HTML, CSS, JavaScript for beginnersPrakritiDhang
 
Programming paradigm and web programming
Programming paradigm and web programmingProgramming paradigm and web programming
Programming paradigm and web programmingMohammad Kamrul Hasan
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASSJon Dean
 
HTML Text formatting tags
HTML Text formatting tagsHTML Text formatting tags
HTML Text formatting tagsHimanshu Pathak
 
What are razor pages?
What are razor pages?What are razor pages?
What are razor pages?Mindfire LLC
 
Full stack web development
Full stack web developmentFull stack web development
Full stack web developmentCrampete
 

What's hot (20)

Java script
Java scriptJava script
Java script
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers
 
CSS
CSSCSS
CSS
 
Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development Presentation
 
HTML Start Up - Introduction to HTML
HTML Start Up - Introduction to HTMLHTML Start Up - Introduction to HTML
HTML Start Up - Introduction to HTML
 
ASP.NET Developer Roadmap 2021
ASP.NET Developer Roadmap 2021ASP.NET Developer Roadmap 2021
ASP.NET Developer Roadmap 2021
 
Bootstrap Part - 1
Bootstrap Part - 1Bootstrap Part - 1
Bootstrap Part - 1
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
Web-Development-ppt.pptx
Web-Development-ppt.pptxWeb-Development-ppt.pptx
Web-Development-ppt.pptx
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
 
Html
HtmlHtml
Html
 
Css selectors
Css selectorsCss selectors
Css selectors
 
HTML, CSS, JavaScript for beginners
HTML, CSS, JavaScript for beginnersHTML, CSS, JavaScript for beginners
HTML, CSS, JavaScript for beginners
 
Css
CssCss
Css
 
Programming paradigm and web programming
Programming paradigm and web programmingProgramming paradigm and web programming
Programming paradigm and web programming
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
HTML Text formatting tags
HTML Text formatting tagsHTML Text formatting tags
HTML Text formatting tags
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
 
What are razor pages?
What are razor pages?What are razor pages?
What are razor pages?
 
Full stack web development
Full stack web developmentFull stack web development
Full stack web development
 

Viewers also liked

Using Content Delivery Networks with Drupal
Using Content Delivery Networks with DrupalUsing Content Delivery Networks with Drupal
Using Content Delivery Networks with Drupalcgmonroe
 
Congress powerpoint (final)
Congress powerpoint (final)Congress powerpoint (final)
Congress powerpoint (final)shaw swafford
 
Powers of 10
Powers of 10Powers of 10
Powers of 10Earl Cote
 
Eval 4 construction
Eval 4 constructionEval 4 construction
Eval 4 constructionhamsterlife
 
2009 Retail Development Seminar
2009 Retail Development Seminar2009 Retail Development Seminar
2009 Retail Development SeminarStephanie Lindley
 
Savior Skin Template
Savior Skin TemplateSavior Skin Template
Savior Skin TemplateMarcMooney
 
οι 3 φάκελοι
οι 3 φάκελοιοι 3 φάκελοι
οι 3 φάκελοιatanatsis
 
Getting to the Heart of the Matter: Communities and Health Systems Strengthening
Getting to the Heart of the Matter: Communities and Health Systems StrengtheningGetting to the Heart of the Matter: Communities and Health Systems Strengthening
Getting to the Heart of the Matter: Communities and Health Systems Strengtheningjehill3
 
Incidence of posterior capsular opacification in rigid pmma
Incidence of posterior capsular opacification in rigid pmmaIncidence of posterior capsular opacification in rigid pmma
Incidence of posterior capsular opacification in rigid pmmaDr. Anand Sudhalkar
 
Changing trends in ophthalmic practice 2
Changing trends in ophthalmic practice 2Changing trends in ophthalmic practice 2
Changing trends in ophthalmic practice 2Dr. Anand Sudhalkar
 
Partnership Defined Quality: Acting it Out!
Partnership Defined Quality: Acting it Out!Partnership Defined Quality: Acting it Out!
Partnership Defined Quality: Acting it Out!jehill3
 
Laerdal: Helping Save Lives
Laerdal: Helping Save LivesLaerdal: Helping Save Lives
Laerdal: Helping Save Livesjehill3
 
Community Mobilization: Indonesia MITRA TB Project
Community Mobilization: Indonesia MITRA TB ProjectCommunity Mobilization: Indonesia MITRA TB Project
Community Mobilization: Indonesia MITRA TB Projectjehill3
 
Space Camp Barcelona 2010 - English
Space Camp Barcelona 2010 - EnglishSpace Camp Barcelona 2010 - English
Space Camp Barcelona 2010 - EnglishXavier Alabart
 
Lives Saved Analyses for Child Survival Projects: Basic How-To Use LiST - Deb...
Lives Saved Analyses for Child Survival Projects: Basic How-To Use LiST - Deb...Lives Saved Analyses for Child Survival Projects: Basic How-To Use LiST - Deb...
Lives Saved Analyses for Child Survival Projects: Basic How-To Use LiST - Deb...jehill3
 
Polynomials
PolynomialsPolynomials
Polynomialsnina
 
European Financial News Distribution Bmb 2010
European Financial News Distribution Bmb 2010European Financial News Distribution Bmb 2010
European Financial News Distribution Bmb 2010Brazil Means Business
 

Viewers also liked (20)

Using Content Delivery Networks with Drupal
Using Content Delivery Networks with DrupalUsing Content Delivery Networks with Drupal
Using Content Delivery Networks with Drupal
 
Congress powerpoint (final)
Congress powerpoint (final)Congress powerpoint (final)
Congress powerpoint (final)
 
European Venture Market
European Venture MarketEuropean Venture Market
European Venture Market
 
Powers of 10
Powers of 10Powers of 10
Powers of 10
 
Eval 4 construction
Eval 4 constructionEval 4 construction
Eval 4 construction
 
2009 Retail Development Seminar
2009 Retail Development Seminar2009 Retail Development Seminar
2009 Retail Development Seminar
 
Savior Skin Template
Savior Skin TemplateSavior Skin Template
Savior Skin Template
 
οι 3 φάκελοι
οι 3 φάκελοιοι 3 φάκελοι
οι 3 φάκελοι
 
Getting to the Heart of the Matter: Communities and Health Systems Strengthening
Getting to the Heart of the Matter: Communities and Health Systems StrengtheningGetting to the Heart of the Matter: Communities and Health Systems Strengthening
Getting to the Heart of the Matter: Communities and Health Systems Strengthening
 
Incidence of posterior capsular opacification in rigid pmma
Incidence of posterior capsular opacification in rigid pmmaIncidence of posterior capsular opacification in rigid pmma
Incidence of posterior capsular opacification in rigid pmma
 
Dinnershow of Dreams
Dinnershow of DreamsDinnershow of Dreams
Dinnershow of Dreams
 
Changing trends in ophthalmic practice 2
Changing trends in ophthalmic practice 2Changing trends in ophthalmic practice 2
Changing trends in ophthalmic practice 2
 
Partnership Defined Quality: Acting it Out!
Partnership Defined Quality: Acting it Out!Partnership Defined Quality: Acting it Out!
Partnership Defined Quality: Acting it Out!
 
Laerdal: Helping Save Lives
Laerdal: Helping Save LivesLaerdal: Helping Save Lives
Laerdal: Helping Save Lives
 
Community Mobilization: Indonesia MITRA TB Project
Community Mobilization: Indonesia MITRA TB ProjectCommunity Mobilization: Indonesia MITRA TB Project
Community Mobilization: Indonesia MITRA TB Project
 
Space Camp Barcelona 2010 - English
Space Camp Barcelona 2010 - EnglishSpace Camp Barcelona 2010 - English
Space Camp Barcelona 2010 - English
 
Lives Saved Analyses for Child Survival Projects: Basic How-To Use LiST - Deb...
Lives Saved Analyses for Child Survival Projects: Basic How-To Use LiST - Deb...Lives Saved Analyses for Child Survival Projects: Basic How-To Use LiST - Deb...
Lives Saved Analyses for Child Survival Projects: Basic How-To Use LiST - Deb...
 
Polynomials
PolynomialsPolynomials
Polynomials
 
Crm
CrmCrm
Crm
 
European Financial News Distribution Bmb 2010
European Financial News Distribution Bmb 2010European Financial News Distribution Bmb 2010
European Financial News Distribution Bmb 2010
 

Similar to Intro to CSS Selectors in Drupal

Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS PresentationShawn Calvert
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
SMACSS Your Sass Up
SMACSS Your Sass UpSMACSS Your Sass Up
SMACSS Your Sass UpMina Markham
 
Css for Development
Css for DevelopmentCss for Development
Css for Developmenttsengsite
 
3 css essentials
3 css essentials3 css essentials
3 css essentialsAnchu S
 
Web Programming& Scripting Lab
Web Programming& Scripting LabWeb Programming& Scripting Lab
Web Programming& Scripting LabSwapnali Pawar
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.pptdatapro2
 
3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.ppt3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.pptmohamed abd elrazek
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.pptscet315
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Likitha47
 
SharePointfest Denver - A jQuery Primer for SharePoint
SharePointfest Denver -  A jQuery Primer for SharePointSharePointfest Denver -  A jQuery Primer for SharePoint
SharePointfest Denver - A jQuery Primer for SharePointMarc D Anderson
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LAJake Johnson
 
CSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersCSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersDarren Gideon
 
Lecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptxLecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptxGmachImen
 
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
 

Similar to Intro to CSS Selectors in Drupal (20)

Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
SMACSS Workshop
SMACSS WorkshopSMACSS Workshop
SMACSS Workshop
 
SMACSS Your Sass Up
SMACSS Your Sass UpSMACSS Your Sass Up
SMACSS Your Sass Up
 
Css for Development
Css for DevelopmentCss for Development
Css for Development
 
3 css essentials
3 css essentials3 css essentials
3 css essentials
 
Web Programming& Scripting Lab
Web Programming& Scripting LabWeb Programming& Scripting Lab
Web Programming& Scripting Lab
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.ppt
 
3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.ppt3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.ppt
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.ppt
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01
 
SharePointfest Denver - A jQuery Primer for SharePoint
SharePointfest Denver -  A jQuery Primer for SharePointSharePointfest Denver -  A jQuery Primer for SharePoint
SharePointfest Denver - A jQuery Primer for SharePoint
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LA
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
 
Lecture2
Lecture2Lecture2
Lecture2
 
CSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersCSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI Developers
 
Lecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptxLecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptx
 
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
 
Creative Web 2 - CSS
Creative Web 2 - CSS Creative Web 2 - CSS
Creative Web 2 - CSS
 

More from cgmonroe

Structured SEO Data Overview and How To
Structured SEO Data Overview and How ToStructured SEO Data Overview and How To
Structured SEO Data Overview and How Tocgmonroe
 
Structured SEO Data: An overview and how to for Drupal
Structured SEO Data:  An overview and how to for DrupalStructured SEO Data:  An overview and how to for Drupal
Structured SEO Data: An overview and how to for Drupalcgmonroe
 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)cgmonroe
 
Tips on Securing Drupal Sites
Tips on Securing Drupal SitesTips on Securing Drupal Sites
Tips on Securing Drupal Sitescgmonroe
 
Becoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search APIBecoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search APIcgmonroe
 
Intro to drupal module internals asheville
Intro to drupal module internals ashevilleIntro to drupal module internals asheville
Intro to drupal module internals ashevillecgmonroe
 
Solr facets and custom indices
Solr facets and custom indicesSolr facets and custom indices
Solr facets and custom indicescgmonroe
 
HTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEHTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEcgmonroe
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features APIcgmonroe
 
The Drupal Strongarm Module - Tips and Tricks.
The Drupal Strongarm Module - Tips and Tricks.The Drupal Strongarm Module - Tips and Tricks.
The Drupal Strongarm Module - Tips and Tricks.cgmonroe
 
Drupal Workflow Concepts
Drupal Workflow ConceptsDrupal Workflow Concepts
Drupal Workflow Conceptscgmonroe
 
TriDUG WebFM Presentation
TriDUG WebFM PresentationTriDUG WebFM Presentation
TriDUG WebFM Presentationcgmonroe
 

More from cgmonroe (12)

Structured SEO Data Overview and How To
Structured SEO Data Overview and How ToStructured SEO Data Overview and How To
Structured SEO Data Overview and How To
 
Structured SEO Data: An overview and how to for Drupal
Structured SEO Data:  An overview and how to for DrupalStructured SEO Data:  An overview and how to for Drupal
Structured SEO Data: An overview and how to for Drupal
 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
 
Tips on Securing Drupal Sites
Tips on Securing Drupal SitesTips on Securing Drupal Sites
Tips on Securing Drupal Sites
 
Becoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search APIBecoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search API
 
Intro to drupal module internals asheville
Intro to drupal module internals ashevilleIntro to drupal module internals asheville
Intro to drupal module internals asheville
 
Solr facets and custom indices
Solr facets and custom indicesSolr facets and custom indices
Solr facets and custom indices
 
HTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEHTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCE
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features API
 
The Drupal Strongarm Module - Tips and Tricks.
The Drupal Strongarm Module - Tips and Tricks.The Drupal Strongarm Module - Tips and Tricks.
The Drupal Strongarm Module - Tips and Tricks.
 
Drupal Workflow Concepts
Drupal Workflow ConceptsDrupal Workflow Concepts
Drupal Workflow Concepts
 
TriDUG WebFM Presentation
TriDUG WebFM PresentationTriDUG WebFM Presentation
TriDUG WebFM Presentation
 

Recently uploaded

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Recently uploaded (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Intro to CSS Selectors in Drupal

  • 1. An Introduction to CSS Selectors and Drupal Understanding CSS selectors and how Drupal allows you to use them to style pages is a key Drupal skill
  • 2. Audience Knowledge Quiz How many… …know what CSS stands for …have “cut & pasted” CSS into sites …have written their own CSS rules from scratch …know what a CSS Selector is …are experts, just here to heckle
  • 3. Why Should You Know This Turn this: Into this… with CSS
  • 4. CSS Rule Syntax Example: CSS Syntax: CSS: <Selector> { A.menu:hover { color: #002b70; <property>: <value>; text-decoration: underline; <property>: <value>; } … HTML: } <UL> <LI> <A class=“menu” href=“foobar.html”>FooBar</A> </LI> </UL>
  • 5. What are Selectors Patterns used to select the parts of a document to apply the styles to. The CSS3 spec define these patterns as: A chain of one or more sequence of simple selectors separated by combinators Lets break this down…
  • 6. Sequence of Simple Selectors The most common simple selector types are: .<class> select all elements with class=“<class>” <element> match a specific HTML <element> (A, H2) #<id> match element with id=<id> attribute :<pseudo> “pseudo class” selectors like :hover, :visited These can be combined into sequences to target specific document element like: A.menu:hover H1 #header Note: There are a lot of other simple selectors, especially with CSS3. See: http://www.w3.org/TR/css3-selectors/#selectors
  • 7. What are Combinators Combinators let you combine sequences of simple selectors (S3) and target very specific areas of a document. Combinators are the most important CSS item to understand with Drupal! They let you target almost anything on a Drupal page
  • 8. Combinators escendant – S3 S3… Elements that are contained inside another element. For example, the selector: IV.menu A:hover ould define the hover style for any anchor tag inside a div with class menu, even if there are other tags between.
  • 9. Combinators hild – S3 > S3… Describes elements that have a direct parent and child relationship: L.menu > LI.leaf ould target ONLY <LI class=“leaf”> elements that were directly under a <UL class=“menu”> element. ibling – S3 + S3… or S3 ~ S3
  • 10. Specificity (The Great Gotcha) Complex CSS selectors will overlap with more than one rule applying to an element. Specificity defines how browsers should calculate the “weight” of rules. The heavier ones win. Drupal tends to have LOTS of rules so chances are your carefully crafted selector may not work. Here’s how specificity is calculated: http://www.w3.org/TR/css3-selectors/#specificity
  • 11. Something !Important One trick to remember if your selector is not specific enough is the !important property declaration. E.g., if these rules point to the same DIV, the text color will be red (#id is highly specific). Div#more_specific { color: red; } Div.less_specific { color: green; } If you add, !important to the properties, the color will be green. Div#more_specific { color: red; } Div.less_specific { color: green !important; }
  • 12. Drupal Areas Drupal pages have a wide variety of CSS addressable “areas” that are created by the system and themes. •Page info •Theme regions •Nodes (Content type/Specific) •Blocks (General / Specific ) •Menus (General / Specific ) •Views (General / Specific ) •Fields - Views & CCK (General / Specific ) •Form elements (General / Specific )
  • 13. Page Info The body tag on Drupal pages will have several useful classes. Front/Not-Front: Front page or not Logged-in/not-logged in: User or Anonymous Node-Type-<node-type>: Class based on Node Type
  • 15. Theme Regions Page Top: <div id=“page-top” class=“region-page-top…. Header: <div id=“header-group” class=“header-group… Sidebar First: <div id=“sidebar-first” class=“region-sidebar-first… Footer: <div id=“footer” class=“region-footer… Content: <div id=“content” class=“region-content… Example CSS #sidebar-first DIV.block { padding-top: 15px; }
  • 17. Nodes, Blocks, & Menus Node: <div id=“node-2” class=“node node-page full-node… Block: <div id=“block-block-2” class=“block… Menu: <div id=“block-system-main-menu” class=“block block-system block-menu… Example CSS #block-block2 .content { background-image: url("../images/SkylarkingDef2.gif"); background-repeat: no-repeat; width: 151px; height: 308px;; }
  • 18. Views & View Fields
  • 19. Views & View Fields View: <div class=“view view-photo-galleries… Field: <div class=“views-field views-field-title… Example CSS .view-photo-galleries .views-field-title { padding-bottom: 6px; } .view-photo-galleries .views-field-title A { font-size: 18px; }
  • 21. CCK Fields Field: <div class=“field field-name-field-quest… Field Label: <div class=“field-label… Field Items: <div class=“field-items… Field Item: <div class=“field-item… Example CSS .node-field-example .field DIV.field-label { padding: 1em 0; } .node-field-example .field DIV.items { padding: 1em 0 2em 1em; }
  • 22. Form Fields No examples prepared, but forms are similar to CCK / Node fields.
  • 23. Helpful Tools FireFox with FireBug Chrome with built in Explore Element
  • 24. Questions? This has covered a lot of complex concepts quickly….