SlideShare a Scribd company logo
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

presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
FaysalAhammed5
 
Preparing for Acquia Certification
Preparing for Acquia CertificationPreparing for Acquia Certification
Preparing for Acquia CertificationAcquia
 
CSS Font & Text style
CSS Font & Text style CSS Font & Text style
CSS Font & Text style
Yaowaluck Promdee
 
CSS
CSSCSS
Lab#9 graphic and color
Lab#9 graphic and colorLab#9 graphic and color
Lab#9 graphic and color
Yaowaluck Promdee
 
HTML + CSS Examples
HTML + CSS ExamplesHTML + CSS Examples
HTML + CSS Examples
Mohamed Loey
 
BEM - CSS, Seriously
BEM - CSS, SeriouslyBEM - CSS, Seriously
BEM - CSS, Seriously
Roland Lösslein
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
iFour Technolab Pvt. Ltd.
 
Design sitemap
Design sitemapDesign sitemap
Design sitemap
Yaowaluck Promdee
 
Css ppt
Css pptCss ppt
Css ppt
Nidhi mishra
 
Lab#7 CSS Box Model
Lab#7 CSS Box ModelLab#7 CSS Box Model
Lab#7 CSS Box Model
Yaowaluck Promdee
 
Css
CssCss
CSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive Design
Zoe Gillenwater
 
Web Application Development Fundamentals
Web Application Development FundamentalsWeb Application Development Fundamentals
Web Application Development Fundamentals
Mohammed Makhlouf
 
Tables and forms with HTML, CSS
Tables and forms with HTML, CSS  Tables and forms with HTML, CSS
Tables and forms with HTML, CSS
Yaowaluck Promdee
 
Navigation and Link
Navigation and LinkNavigation and Link
Navigation and Link
Yaowaluck Promdee
 
Css and its types
Css and its typesCss and its types
Css and its types
Mansi Mahadik
 
Initiation html css
Initiation html cssInitiation html css
Initiation html css
thamer belfkih
 

What's hot (20)

presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
 
Preparing for Acquia Certification
Preparing for Acquia CertificationPreparing for Acquia Certification
Preparing for Acquia Certification
 
CSS Font & Text style
CSS Font & Text style CSS Font & Text style
CSS Font & Text style
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
Lab#9 graphic and color
Lab#9 graphic and colorLab#9 graphic and color
Lab#9 graphic and color
 
HTML + CSS Examples
HTML + CSS ExamplesHTML + CSS Examples
HTML + CSS Examples
 
BEM - CSS, Seriously
BEM - CSS, SeriouslyBEM - CSS, Seriously
BEM - CSS, Seriously
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
 
Design sitemap
Design sitemapDesign sitemap
Design sitemap
 
Css ppt
Css pptCss ppt
Css ppt
 
Lab#7 CSS Box Model
Lab#7 CSS Box ModelLab#7 CSS Box Model
Lab#7 CSS Box Model
 
Css
CssCss
Css
 
CSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive Design
 
Web Application Development Fundamentals
Web Application Development FundamentalsWeb Application Development Fundamentals
Web Application Development Fundamentals
 
Tables and forms with HTML, CSS
Tables and forms with HTML, CSS  Tables and forms with HTML, CSS
Tables and forms with HTML, CSS
 
Navigation and Link
Navigation and LinkNavigation and Link
Navigation and Link
 
Css and its types
Css and its typesCss and its types
Css and its types
 
HTML5 & CSS3
HTML5 & CSS3 HTML5 & CSS3
HTML5 & CSS3
 
Initiation html css
Initiation html cssInitiation html css
Initiation html css
 

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 Drupal
cgmonroe
 
Congress powerpoint (final)
Congress powerpoint (final)Congress powerpoint (final)
Congress powerpoint (final)shaw swafford
 
European Venture Market
European Venture MarketEuropean Venture Market
European Venture Market
Continua Unternehmensentwicklung GmbH
 
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 Strengthening
jehill3
 
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 Lives
jehill3
 
Community Mobilization: Indonesia MITRA TB Project
Community Mobilization: Indonesia MITRA TB ProjectCommunity Mobilization: Indonesia MITRA TB Project
Community Mobilization: Indonesia MITRA TB Project
jehill3
 
Space Camp Barcelona 2010 - English
Space Camp Barcelona 2010 - EnglishSpace Camp Barcelona 2010 - English
Space Camp Barcelona 2010 - English
Xavier 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 2010
Brazil 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 Presentation
Shawn Calvert
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
William Myers
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
SMACSS Workshop
SMACSS WorkshopSMACSS Workshop
SMACSS Workshop
Tim Hettler
 
SMACSS Your Sass Up
SMACSS Your Sass UpSMACSS Your Sass Up
SMACSS Your Sass Up
Mina Markham
 
Css for Development
Css for DevelopmentCss for Development
Css for Developmenttsengsite
 
3 css essentials
3 css essentials3 css essentials
3 css essentials
Anchu S
 
Web Programming& Scripting Lab
Web Programming& Scripting LabWeb Programming& Scripting Lab
Web Programming& Scripting Lab
Swapnali Pawar
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.ppt
datapro2
 
3-CSS_essentials introduction slides.ppt
3-CSS_essentials introduction slides.ppt3-CSS_essentials introduction slides.ppt
3-CSS_essentials introduction slides.ppt
Aasma13
 
3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.ppt3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.ppt
mohamed abd elrazek
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.ppt
scet315
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01
Likitha47
 
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
Marc D Anderson
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LA
Jake Johnson
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
William Myers
 
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
Darren Gideon
 
Lecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptxLecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptx
GmachImen
 
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 introduction slides.ppt
3-CSS_essentials introduction slides.ppt3-CSS_essentials introduction slides.ppt
3-CSS_essentials introduction slides.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
 

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 To
cgmonroe
 
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
cgmonroe
 
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 Sites
cgmonroe
 
Becoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search APIBecoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search API
cgmonroe
 
Intro to drupal module internals asheville
Intro to drupal module internals ashevilleIntro to drupal module internals asheville
Intro to drupal module internals asheville
cgmonroe
 
Solr facets and custom indices
Solr facets and custom indicesSolr facets and custom indices
Solr facets and custom indices
cgmonroe
 
HTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEHTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCE
cgmonroe
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features API
cgmonroe
 
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 Concepts
cgmonroe
 
TriDUG WebFM Presentation
TriDUG WebFM PresentationTriDUG WebFM Presentation
TriDUG WebFM Presentation
cgmonroe
 

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

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

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….