SlideShare a Scribd company logo
TMW Code Club
TMW Code Club
Week 2: CSS – The fundamentals
TMW Code Club
Do you know more than
this guy?
TMW Code Club
Recap
TMW Code Club
HTML, CSS, JavaScriptContent Styling Behaviour
Text, images, video
Colours, borders,
backgrounds, shadows
Click, touch,
scroll, hover
TMW Code Club
Week 2
CSS – The basics
• The cascade
• Importance, specificity and source order
• Classes and IDs
• CSS properties and terminology
TMW Code Club
CSS
Cascading Style Sheets
TMW Code Club
By combining importance, origin, specificity, and
the source order of the style concerned, the CSS
cascade assigns a weight to each declaration. This
weight is used to determine exactly, and without
conflict, which style declarations should be applied
to a specific element: the declaration with the
highest weight takes precedence.
What is this cascade?
http://reference.sitepoint.com/css/cascade
7
TMW Code Club
By combining importance, origin, specificity, and
the source order of the style concerned, the CSS
cascade assigns a weight to each declaration. This
weight is used to determine exactly, and without
conflict, which style declarations should be applied
to a specific element: the declaration with the
highest weight takes precedence.
What is this cascade?
http://reference.sitepoint.com/css/cascade
8
TMW Code Club
Remember this?
TMW Code Club
What happens here?
TMW Code Club
Let’s try it for real
codepen.io/mrmartineau/pen/nfDcE
TMW Code Club
Selectors
• Element
• Classes
• IDs
• Complex selectors
TMW Code Club
Element selectors
• Matches elements with the corresponding
element type name
• Quite general and not very specific.
TMW Code Club
What are classes and IDs?
When there are more than one of a given element
on the page, and you need to look different, you
will need to use classes and IDs.
<div></div>
!
<div id=“foo”></div>
!
<div class=“bar”></div>
Element:
!
ID:
!
Class:
TMW Code Club
What are classes and IDs?
• IDs are unique. Only one allowed per page.
• Multiple classes can be used per page &
elements can even have multiple classes
<div></div>
!
<div id=“foo”></div>
!
<div class=“bar”></div>
Element:
!
ID:
!
Class:
TMW Code Club
ID selectors
Matches an element that has a specific id attribute
value. Since id attributes must have unique values,
an ID selector can never match more than one
element in a document.
TMW Code Club
Class selectors
Less specific than an ID because they are not unique
TMW Code Club
More complex selectors
Siblings, Children and descendent selectors
TMW Code Club
Selector examples
codepen.io/mrmartineau/pen/jgCvq
TMW Code Club
CSS Properties
Basic Styling
TMW Code Club
color
(or colour)
TMW Code Club
color
(or colour)
The color property sets the text colour of an
elements content, and it’s decorations (such as
underlines, or line throughs).
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/color
TMW Code Club
color
(or colour)
Colours in CSS can be defined in a number of ways.
To set our text colour to black, we could define it…
!
…as a hex code = #000 = #000000
…an RGB value = rgb(0, 0, 0)
…an hsl value = hsl(0%, 0%, 0%)
…or using the reserved CSS keyword ‘black’
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
TMW Code Club
color
(or colour)
You can also set colours for the following properties:
!
background-color!
color!
border-color!
TMW Code Club
color example
codepen.io/ashleynolan/pen/Blnkc
TMW Code Club
background
TMW Code Club
background
The background property allows you to control the
background of any element.
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/background
TMW Code Club
background
Can be an image:
background-image: url(‘myimage.png’);!
!
or a color, as mentioned before:
background-color: #fff;
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/background
TMW Code Club
background
Some properties have a shortcut alternative, in
which you can specify multiple properties at once.
!
background-color: #fff;!
background-image: url(‘myimage.png’);!
becomes
background: #fff url(‘myimage.png’);
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/background
TMW Code Club
background
background also has other properties
!
background-image!
background-position!
background-repeat!
background-color
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/background
TMW Code Club
background example
http://codepen.io/ashleynolan/pen/dxocr
TMW Code Club
text properties
TMW Code Club
text properties
Text has a number of CSS properties that can be applied.
More info: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-size
TMW Code Club
font-size
text properties
font-size can be defined in px
(as well as a few other ways which we‘ll get to in a later lesson)
!
font-size: 16px;
More info: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-size
TMW Code Club
line-height
text properties
line-height can also be defined in px, but can also be
unitless, which is relative to the font-size
!
line-height: 16px;!
or
line-height: 1.5;!
where the line-height is multiplied by the font-size
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
TMW Code Club
text decoration
text properties
Text can be given a text-decoration
!
So for example, links (<a> tags) have the following by default:
!
text-decoration: underline;!
!
It takes the following values:
underline, line-through or overline!
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration
TMW Code Club
text shadow
text properties
Text can also be given a shadow
!
text-shadow: 0 -2px #000;
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow
TMW Code Club
text examples
Text decoration: codepen.io/ashleynolan/pen/pxnCc
!
Text shadow: codepen.io/ashleynolan/pen/zrLlv
!
Text shadow example: codepen.io/juanbrujo/pen/yGpAK
TMW Code Club
Homework!
Style up the earlier codepen example to have a custom
styled title and paragraph text. Use any of the CSS
properties we've seen today.
!
http://codepen.io/ashleynolan/pen/Blnkc

More Related Content

PDF
PDF
[Worskhop Summits] CSS3 Workshop
PPTX
How to dominate a free theme WCTO 2014
PDF
01 Introduction To CSS
PPTX
Hammersmith fundamentals html fundamentals
KEY
Artdm171 Week5 Css
PPT
PDF
CSS3 Media Queries
[Worskhop Summits] CSS3 Workshop
How to dominate a free theme WCTO 2014
01 Introduction To CSS
Hammersmith fundamentals html fundamentals
Artdm171 Week5 Css
CSS3 Media Queries

What's hot (20)

PPTX
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
PDF
Intro to Sass for WordPress Developers
PDF
OOCSS, SMACSS or BEM?
PDF
How to use CSS3 in WordPress - Sacramento
PPTX
Wp responsive-theme-framework
PPT
An Introduction to Custom Post Types
PDF
Wrangling Themes: everything you need to know about WordPress themes
PDF
Wrangling Themes: everything you need to know about WordPress themes
PDF
Intro to css & sass
PDF
How to use CSS3 in WordPress
PPTX
Internet tech &amp; web prog. p4,5
PPTX
Word press course
KEY
Trendsetting: Web Design and Beyond
KEY
Sass: The Future of Stylesheets
PPTX
Word press bootcamp By Sourcescript Innovations and Mentors Dojo
PDF
Introduction to CSS3
PDF
Intro to CSS3
PPTX
Css 3
PPTX
Css 3
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
Intro to Sass for WordPress Developers
OOCSS, SMACSS or BEM?
How to use CSS3 in WordPress - Sacramento
Wp responsive-theme-framework
An Introduction to Custom Post Types
Wrangling Themes: everything you need to know about WordPress themes
Wrangling Themes: everything you need to know about WordPress themes
Intro to css & sass
How to use CSS3 in WordPress
Internet tech &amp; web prog. p4,5
Word press course
Trendsetting: Web Design and Beyond
Sass: The Future of Stylesheets
Word press bootcamp By Sourcescript Innovations and Mentors Dojo
Introduction to CSS3
Intro to CSS3
Css 3
Css 3
Ad

Viewers also liked (18)

PDF
Navapalos tomo I
PDF
Scaling Responsively
PDF
Exploring Our Front-End Workflows
PDF
Developing for the Unknown
PPTX
Questions that we are afraid to ask...
PPTX
tcp atau ip
PDF
Jack
PDF
Family
PDF
TMW Code Club Session 1
PDF
Think Before You Speak
PPTX
Schools, families, and communities week one
PPT
Reported speech
PDF
Sand and Stone
PDF
CSS Best Practices
PPTX
The Lion and the Rabbit
PDF
The Most Beautiful Heart
PDF
Reworking our-workflows
PPTX
Scissor bite
Navapalos tomo I
Scaling Responsively
Exploring Our Front-End Workflows
Developing for the Unknown
Questions that we are afraid to ask...
tcp atau ip
Jack
Family
TMW Code Club Session 1
Think Before You Speak
Schools, families, and communities week one
Reported speech
Sand and Stone
CSS Best Practices
The Lion and the Rabbit
The Most Beautiful Heart
Reworking our-workflows
Scissor bite
Ad

Similar to TMW Code Club – Session 2 - CSS Basics (20)

PPT
CSS Methodology
PPT
Even faster web sites presentation 3
PDF
introduction to css cascading style sheets
PPT
introductiontohtmlcss-part2-120711042239-phpapp02.ppt
PPTX
CSS101 - Concept Fundamentals for non UI Developers
PDF
CSS workshop @ OutSystems
PPT
PPT
css.ppt
PPT
HTML Web Devlopment presentation css.ppt
PPT
Rational HATS and CSS
PPT
Css Founder.com | Cssfounder org
PPTX
Css basics
PPT
Introduction to CSS
PDF
9- Learn CSS Fundamentals / Pseudo-classes
PPT
An Introduction to CSS
PPT
CSS: How To Learn Easily
PPTX
NEPA BlogCon 2013 - WordPress Customization & Security
PPTX
css v1 guru
PPT
Css week11 2020 2021 for g10 by eng.osama ghandour
CSS Methodology
Even faster web sites presentation 3
introduction to css cascading style sheets
introductiontohtmlcss-part2-120711042239-phpapp02.ppt
CSS101 - Concept Fundamentals for non UI Developers
CSS workshop @ OutSystems
css.ppt
HTML Web Devlopment presentation css.ppt
Rational HATS and CSS
Css Founder.com | Cssfounder org
Css basics
Introduction to CSS
9- Learn CSS Fundamentals / Pseudo-classes
An Introduction to CSS
CSS: How To Learn Easily
NEPA BlogCon 2013 - WordPress Customization & Security
css v1 guru
Css week11 2020 2021 for g10 by eng.osama ghandour

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Spectroscopy.pptx food analysis technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
PPT
Teaching material agriculture food technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Approach and Philosophy of On baking technology
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Advanced methodologies resolving dimensionality complications for autism neur...
Spectroscopy.pptx food analysis technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
Teaching material agriculture food technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation_ Review paper, used for researhc scholars
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Review of recent advances in non-invasive hemoglobin estimation
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Approach and Philosophy of On baking technology
The Rise and Fall of 3GPP – Time for a Sabbatical?
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing

TMW Code Club – Session 2 - CSS Basics

  • 1. TMW Code Club TMW Code Club Week 2: CSS – The fundamentals
  • 2. TMW Code Club Do you know more than this guy?
  • 4. TMW Code Club HTML, CSS, JavaScriptContent Styling Behaviour Text, images, video Colours, borders, backgrounds, shadows Click, touch, scroll, hover
  • 5. TMW Code Club Week 2 CSS – The basics • The cascade • Importance, specificity and source order • Classes and IDs • CSS properties and terminology
  • 7. TMW Code Club By combining importance, origin, specificity, and the source order of the style concerned, the CSS cascade assigns a weight to each declaration. This weight is used to determine exactly, and without conflict, which style declarations should be applied to a specific element: the declaration with the highest weight takes precedence. What is this cascade? http://reference.sitepoint.com/css/cascade 7
  • 8. TMW Code Club By combining importance, origin, specificity, and the source order of the style concerned, the CSS cascade assigns a weight to each declaration. This weight is used to determine exactly, and without conflict, which style declarations should be applied to a specific element: the declaration with the highest weight takes precedence. What is this cascade? http://reference.sitepoint.com/css/cascade 8
  • 10. TMW Code Club What happens here?
  • 11. TMW Code Club Let’s try it for real codepen.io/mrmartineau/pen/nfDcE
  • 12. TMW Code Club Selectors • Element • Classes • IDs • Complex selectors
  • 13. TMW Code Club Element selectors • Matches elements with the corresponding element type name • Quite general and not very specific.
  • 14. TMW Code Club What are classes and IDs? When there are more than one of a given element on the page, and you need to look different, you will need to use classes and IDs. <div></div> ! <div id=“foo”></div> ! <div class=“bar”></div> Element: ! ID: ! Class:
  • 15. TMW Code Club What are classes and IDs? • IDs are unique. Only one allowed per page. • Multiple classes can be used per page & elements can even have multiple classes <div></div> ! <div id=“foo”></div> ! <div class=“bar”></div> Element: ! ID: ! Class:
  • 16. TMW Code Club ID selectors Matches an element that has a specific id attribute value. Since id attributes must have unique values, an ID selector can never match more than one element in a document.
  • 17. TMW Code Club Class selectors Less specific than an ID because they are not unique
  • 18. TMW Code Club More complex selectors Siblings, Children and descendent selectors
  • 19. TMW Code Club Selector examples codepen.io/mrmartineau/pen/jgCvq
  • 20. TMW Code Club CSS Properties Basic Styling
  • 22. TMW Code Club color (or colour) The color property sets the text colour of an elements content, and it’s decorations (such as underlines, or line throughs). More info: https://developer.mozilla.org/en-US/docs/Web/CSS/color
  • 23. TMW Code Club color (or colour) Colours in CSS can be defined in a number of ways. To set our text colour to black, we could define it… ! …as a hex code = #000 = #000000 …an RGB value = rgb(0, 0, 0) …an hsl value = hsl(0%, 0%, 0%) …or using the reserved CSS keyword ‘black’ More info: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
  • 24. TMW Code Club color (or colour) You can also set colours for the following properties: ! background-color! color! border-color!
  • 25. TMW Code Club color example codepen.io/ashleynolan/pen/Blnkc
  • 27. TMW Code Club background The background property allows you to control the background of any element. More info: https://developer.mozilla.org/en-US/docs/Web/CSS/background
  • 28. TMW Code Club background Can be an image: background-image: url(‘myimage.png’);! ! or a color, as mentioned before: background-color: #fff; More info: https://developer.mozilla.org/en-US/docs/Web/CSS/background
  • 29. TMW Code Club background Some properties have a shortcut alternative, in which you can specify multiple properties at once. ! background-color: #fff;! background-image: url(‘myimage.png’);! becomes background: #fff url(‘myimage.png’); More info: https://developer.mozilla.org/en-US/docs/Web/CSS/background
  • 30. TMW Code Club background background also has other properties ! background-image! background-position! background-repeat! background-color More info: https://developer.mozilla.org/en-US/docs/Web/CSS/background
  • 31. TMW Code Club background example http://codepen.io/ashleynolan/pen/dxocr
  • 32. TMW Code Club text properties
  • 33. TMW Code Club text properties Text has a number of CSS properties that can be applied. More info: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-size
  • 34. TMW Code Club font-size text properties font-size can be defined in px (as well as a few other ways which we‘ll get to in a later lesson) ! font-size: 16px; More info: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-size
  • 35. TMW Code Club line-height text properties line-height can also be defined in px, but can also be unitless, which is relative to the font-size ! line-height: 16px;! or line-height: 1.5;! where the line-height is multiplied by the font-size More info: https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
  • 36. TMW Code Club text decoration text properties Text can be given a text-decoration ! So for example, links (<a> tags) have the following by default: ! text-decoration: underline;! ! It takes the following values: underline, line-through or overline! More info: https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration
  • 37. TMW Code Club text shadow text properties Text can also be given a shadow ! text-shadow: 0 -2px #000; More info: https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow
  • 38. TMW Code Club text examples Text decoration: codepen.io/ashleynolan/pen/pxnCc ! Text shadow: codepen.io/ashleynolan/pen/zrLlv ! Text shadow example: codepen.io/juanbrujo/pen/yGpAK
  • 39. TMW Code Club Homework! Style up the earlier codepen example to have a custom styled title and paragraph text. Use any of the CSS properties we've seen today. ! http://codepen.io/ashleynolan/pen/Blnkc