SlideShare a Scribd company logo
CSS
BEST PRACTICE
Best practice
“Best practice” is a very loose
and often poorly defined term.
“Best practice” often comes down
      to personal opinion.
“Best practice” can depend on the
   team environment you are
            working in.
“Best practice” may also depend
on the applications you have to
            work with.
Your personal “best practices”
may change radically over time!
With that in mind, here are some
 tips that may help you when
setting up CSS files in the future.
Applying CSS
1. Avoid using inline styles as
    they are hard to maintain and
          increase file size.

                           Avoid
<body>
<h2 style=“color: red;”>
!   Heading here
</h2>
2. Avoid using header styles as
     they are also hard to maintain
         and increase file size.


                      Avoid
<style>
  p { color: red; }
</style>
3. Avoid using @import within the
   HTML as this will slow down IE
              browsers.

                     Avoid
<style>
  @import "a.css";
</style>
4. Avoid using multiple CSS
    files, or combine all CSS files
        before final production.

                               Avoid

<link   rel="stylesheet"   href="reset.css">
<link   rel="stylesheet"   href="grids.css">
<link   rel="stylesheet"   href="text.css">
<link   rel="stylesheet"   href="modules.css">
<link   rel="stylesheet"   href="colors.css">
Writing CSS rules
5. Use multiple declarations
           where possible



p
{
!   margin: 0 0 1.5em;
!   background: green;
}
6. Use multiple selectors
           where possible



h1, h2, h3, h4, h5
{
!   color: #666;
!   margin: 0 0 .5em;
}
7. Use shorthand properties
           where possible

body
{                             Avoid
  margin-top: 20px;
  margin-right: 10px;
  margin-bottom: 20px;
  margin-left: 10px;
}                             Preferred

body { margin: 20px 10px; }
8. Avoid !important as it is often
     unnecessary - especially when
      you understand the cascade.


p                           Avoid
{
!   margin: 0 !important;
}
9. Avoid complex selectors
    (taxing for browsers). Try to be
      only as specific as needed.

                        Avoid

#navigation ul li a { margin: 0; }

#navigation a { margin: 0; }

                 Preferred
10. Avoid universal selectors.



          Avoid

.nav * { margin: 0; }
11. Avoid qualifying selectors as
       this is often unnecessary.


              Avoid

div.nav { }

.nav { }

           Preferred
12. Avoid IE-proprietary filters
  as they slow page performance.


            Avoid

filter:Alpha(Opacity=40);
-ms-filter: "Alpha(Opacity=40)";
13. Avoid IDs. Where possible
         use classes instead.


            Avoid

#header { ... }

.header { ... }

         Preferred
14. Try not to use too many
       font-size declarations.



h1 { font-size: 200%; }
                               Avoid
.nav { font-size: 80%; }
.widget { font-size: 70%; }
.intro { font-size: 110%; }
.sidebar { font-size: 85%; }
Optimisation
15. Some people like to use a
 CSS minifier to reduce your
    overall CSS file size:
     http://refresh-sf.com/yui/
16. Optimise images as much as
           possible
17. Where possible, combine
    images into sprites.
18. If possible, use CSS3 rules
     instead of images to reduce
    server requests and page size.

            Avoid

p { background: url(round-corners.png); }

p { border-radius: 10px; }

         Preferred
Russ Weakley
Max Design

Site: maxdesign.com.au
Twitter: twitter.com/russmaxdesign
Slideshare: slideshare.net/maxdesign
Linkedin: linkedin.com/in/russweakley

More Related Content

What's hot (20)

Introduction to css
Introduction to cssIntroduction to css
Introduction to css
Evolution Network
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
Jacob Nelson
 
Bootstrap
BootstrapBootstrap
Bootstrap
Jadson Santos
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
Singsys Pte Ltd
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Arulmurugan Rajaraman
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
Harshita Yadav
 
Css ppt
Css pptCss ppt
Css ppt
Nidhi mishra
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
Knoldus Inc.
 
Responsive web-design through bootstrap
Responsive web-design through bootstrapResponsive web-design through bootstrap
Responsive web-design through bootstrap
Zunair Sagitarioux
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
joilrahat
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
Ana Cidre
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
David Lindkvist
 
CSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreCSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and more
Russ Weakley
 
CSS
CSSCSS
CSS
Akila Iroshan
 
Css animation
Css animationCss animation
Css animation
Aaron King
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
Amit Kumar Singh
 
CSS
CSSCSS
CSS
Raja Kumar Ranjan
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Css selectors
Css selectorsCss selectors
Css selectors
Parth Trivedi
 
Tech talk on Tailwind CSS
Tech talk on Tailwind CSSTech talk on Tailwind CSS
Tech talk on Tailwind CSS
Squareboat
 

Viewers also liked (11)

AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
Henry Tao
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
Betclic Everest Group Tech Team
 
Mobile Email Design, Strategies, Workflow and Best Practices
Mobile Email Design, Strategies, Workflow and Best PracticesMobile Email Design, Strategies, Workflow and Best Practices
Mobile Email Design, Strategies, Workflow and Best Practices
Litmus
 
New Features in Angular 1.5
New Features in Angular 1.5New Features in Angular 1.5
New Features in Angular 1.5
Kenichi Kanai
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015
Matt Raible
 
AngularJS best practices
AngularJS best practicesAngularJS best practices
AngularJS best practices
Filip Bruun Bech-Larsen
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media Queries
Russ Weakley
 
Media queries and frameworks
Media queries and frameworksMedia queries and frameworks
Media queries and frameworks
Nicole Ryan
 
Beyond Media Queries: Anatomy of an Adaptive Web Design
Beyond Media Queries: Anatomy of an Adaptive Web DesignBeyond Media Queries: Anatomy of an Adaptive Web Design
Beyond Media Queries: Anatomy of an Adaptive Web Design
Brad Frost
 
Css best practices style guide and tips
Css best practices style guide and tipsCss best practices style guide and tips
Css best practices style guide and tips
Chris Love
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
Narek Mamikonyan
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
Henry Tao
 
Mobile Email Design, Strategies, Workflow and Best Practices
Mobile Email Design, Strategies, Workflow and Best PracticesMobile Email Design, Strategies, Workflow and Best Practices
Mobile Email Design, Strategies, Workflow and Best Practices
Litmus
 
New Features in Angular 1.5
New Features in Angular 1.5New Features in Angular 1.5
New Features in Angular 1.5
Kenichi Kanai
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015
Matt Raible
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media Queries
Russ Weakley
 
Media queries and frameworks
Media queries and frameworksMedia queries and frameworks
Media queries and frameworks
Nicole Ryan
 
Beyond Media Queries: Anatomy of an Adaptive Web Design
Beyond Media Queries: Anatomy of an Adaptive Web DesignBeyond Media Queries: Anatomy of an Adaptive Web Design
Beyond Media Queries: Anatomy of an Adaptive Web Design
Brad Frost
 
Css best practices style guide and tips
Css best practices style guide and tipsCss best practices style guide and tips
Css best practices style guide and tips
Chris Love
 

Similar to CSS Best practice (20)

Efficient, maintainable CSS
Efficient, maintainable CSSEfficient, maintainable CSS
Efficient, maintainable CSS
Russ Weakley
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
Bastian Grimm
 
CSS3
CSS3CSS3
CSS3
Chathuranga Jayanath
 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern libraries
Russ Weakley
 
Using a CSS Framework
Using a CSS FrameworkUsing a CSS Framework
Using a CSS Framework
Gareth Saunders
 
Team styles
Team stylesTeam styles
Team styles
nathanscott
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
Heather Rock
 
Frontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser renderingFrontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser rendering
Manuel Garcia
 
Web Accessibility for the 21st Century
Web Accessibility for the 21st CenturyWeb Accessibility for the 21st Century
Web Accessibility for the 21st Century
dreamwidth
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
Sanjoy Kr. Paul
 
css-tutorial
css-tutorialcss-tutorial
css-tutorial
tutorialsruby
 
css-tutorial
css-tutorialcss-tutorial
css-tutorial
tutorialsruby
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
Hatem Mahmoud
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
butest
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
butest
 
Css
CssCss
Css
Sumit Gupta
 
CSS Tutorial For Basic Students Studying
CSS Tutorial For Basic Students StudyingCSS Tutorial For Basic Students Studying
CSS Tutorial For Basic Students Studying
nirmala119429
 
An Introduction to CSS Frameworks
An Introduction to CSS FrameworksAn Introduction to CSS Frameworks
An Introduction to CSS Frameworks
Adrian Westlake
 
How to use CSS3 in WordPress
How to use CSS3 in WordPressHow to use CSS3 in WordPress
How to use CSS3 in WordPress
Suzette Franck
 
Efficient, maintainable CSS
Efficient, maintainable CSSEfficient, maintainable CSS
Efficient, maintainable CSS
Russ Weakley
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
Bastian Grimm
 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern libraries
Russ Weakley
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
Heather Rock
 
Frontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser renderingFrontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser rendering
Manuel Garcia
 
Web Accessibility for the 21st Century
Web Accessibility for the 21st CenturyWeb Accessibility for the 21st Century
Web Accessibility for the 21st Century
dreamwidth
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
Sanjoy Kr. Paul
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
Hatem Mahmoud
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
butest
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
butest
 
CSS Tutorial For Basic Students Studying
CSS Tutorial For Basic Students StudyingCSS Tutorial For Basic Students Studying
CSS Tutorial For Basic Students Studying
nirmala119429
 
An Introduction to CSS Frameworks
An Introduction to CSS FrameworksAn Introduction to CSS Frameworks
An Introduction to CSS Frameworks
Adrian Westlake
 
How to use CSS3 in WordPress
How to use CSS3 in WordPressHow to use CSS3 in WordPress
How to use CSS3 in WordPress
Suzette Franck
 

More from Russ Weakley (20)

Accessible chat windows
Accessible chat windowsAccessible chat windows
Accessible chat windows
Russ Weakley
 
Accessible names & descriptions
Accessible names & descriptionsAccessible names & descriptions
Accessible names & descriptions
Russ Weakley
 
A deep dive into accessible names
A deep dive into accessible namesA deep dive into accessible names
A deep dive into accessible names
Russ Weakley
 
What are accessible names and why should you care?
What are accessible names and why should you care?What are accessible names and why should you care?
What are accessible names and why should you care?
Russ Weakley
 
How to build accessible UI components
How to build accessible UI componentsHow to build accessible UI components
How to build accessible UI components
Russ Weakley
 
What is WCAG 2 and why should we care?
What is WCAG 2 and why should we care?What is WCAG 2 and why should we care?
What is WCAG 2 and why should we care?
Russ Weakley
 
Accessible states in Design Systems
Accessible states in Design SystemsAccessible states in Design Systems
Accessible states in Design Systems
Russ Weakley
 
Creating accessible modals and autocompletes
Creating accessible modals and autocompletesCreating accessible modals and autocompletes
Creating accessible modals and autocompletes
Russ Weakley
 
Building an accessible progressive loader
Building an accessible progressive loaderBuilding an accessible progressive loader
Building an accessible progressive loader
Russ Weakley
 
Accessibility in Design systems - the pain and glory
Accessibility in Design systems - the pain and gloryAccessibility in Design systems - the pain and glory
Accessibility in Design systems - the pain and glory
Russ Weakley
 
Accessible Inline errors messages
Accessible Inline errors messagesAccessible Inline errors messages
Accessible Inline errors messages
Russ Weakley
 
Accessible Form Hints and Errors
Accessible Form Hints and ErrorsAccessible Form Hints and Errors
Accessible Form Hints and Errors
Russ Weakley
 
What is accessibility?
What is accessibility?What is accessibility?
What is accessibility?
Russ Weakley
 
Accessibility in Pattern Libraries
Accessibility in Pattern LibrariesAccessibility in Pattern Libraries
Accessibility in Pattern Libraries
Russ Weakley
 
Accessibility in pattern libraries
Accessibility in pattern librariesAccessibility in pattern libraries
Accessibility in pattern libraries
Russ Weakley
 
Building an accessible auto-complete - #ID24
Building an accessible auto-complete - #ID24Building an accessible auto-complete - #ID24
Building an accessible auto-complete - #ID24
Russ Weakley
 
Building an accessible auto-complete
Building an accessible auto-completeBuilding an accessible auto-complete
Building an accessible auto-complete
Russ Weakley
 
Creating Acessible floating labels
Creating Acessible floating labelsCreating Acessible floating labels
Creating Acessible floating labels
Russ Weakley
 
Creating an Accessible button dropdown
Creating an Accessible button dropdownCreating an Accessible button dropdown
Creating an Accessible button dropdown
Russ Weakley
 
Creating a Simple, Accessible On/Off Switch
Creating a Simple, Accessible On/Off SwitchCreating a Simple, Accessible On/Off Switch
Creating a Simple, Accessible On/Off Switch
Russ Weakley
 
Accessible chat windows
Accessible chat windowsAccessible chat windows
Accessible chat windows
Russ Weakley
 
Accessible names & descriptions
Accessible names & descriptionsAccessible names & descriptions
Accessible names & descriptions
Russ Weakley
 
A deep dive into accessible names
A deep dive into accessible namesA deep dive into accessible names
A deep dive into accessible names
Russ Weakley
 
What are accessible names and why should you care?
What are accessible names and why should you care?What are accessible names and why should you care?
What are accessible names and why should you care?
Russ Weakley
 
How to build accessible UI components
How to build accessible UI componentsHow to build accessible UI components
How to build accessible UI components
Russ Weakley
 
What is WCAG 2 and why should we care?
What is WCAG 2 and why should we care?What is WCAG 2 and why should we care?
What is WCAG 2 and why should we care?
Russ Weakley
 
Accessible states in Design Systems
Accessible states in Design SystemsAccessible states in Design Systems
Accessible states in Design Systems
Russ Weakley
 
Creating accessible modals and autocompletes
Creating accessible modals and autocompletesCreating accessible modals and autocompletes
Creating accessible modals and autocompletes
Russ Weakley
 
Building an accessible progressive loader
Building an accessible progressive loaderBuilding an accessible progressive loader
Building an accessible progressive loader
Russ Weakley
 
Accessibility in Design systems - the pain and glory
Accessibility in Design systems - the pain and gloryAccessibility in Design systems - the pain and glory
Accessibility in Design systems - the pain and glory
Russ Weakley
 
Accessible Inline errors messages
Accessible Inline errors messagesAccessible Inline errors messages
Accessible Inline errors messages
Russ Weakley
 
Accessible Form Hints and Errors
Accessible Form Hints and ErrorsAccessible Form Hints and Errors
Accessible Form Hints and Errors
Russ Weakley
 
What is accessibility?
What is accessibility?What is accessibility?
What is accessibility?
Russ Weakley
 
Accessibility in Pattern Libraries
Accessibility in Pattern LibrariesAccessibility in Pattern Libraries
Accessibility in Pattern Libraries
Russ Weakley
 
Accessibility in pattern libraries
Accessibility in pattern librariesAccessibility in pattern libraries
Accessibility in pattern libraries
Russ Weakley
 
Building an accessible auto-complete - #ID24
Building an accessible auto-complete - #ID24Building an accessible auto-complete - #ID24
Building an accessible auto-complete - #ID24
Russ Weakley
 
Building an accessible auto-complete
Building an accessible auto-completeBuilding an accessible auto-complete
Building an accessible auto-complete
Russ Weakley
 
Creating Acessible floating labels
Creating Acessible floating labelsCreating Acessible floating labels
Creating Acessible floating labels
Russ Weakley
 
Creating an Accessible button dropdown
Creating an Accessible button dropdownCreating an Accessible button dropdown
Creating an Accessible button dropdown
Russ Weakley
 
Creating a Simple, Accessible On/Off Switch
Creating a Simple, Accessible On/Off SwitchCreating a Simple, Accessible On/Off Switch
Creating a Simple, Accessible On/Off Switch
Russ Weakley
 

Recently uploaded (20)

Intervene with Precision: Zooming In as a Leader Without Micromanaging
Intervene with Precision: Zooming In as a Leader Without MicromanagingIntervene with Precision: Zooming In as a Leader Without Micromanaging
Intervene with Precision: Zooming In as a Leader Without Micromanaging
victoriamangiantini1
 
Product in Wartime: How to Build When the Market Is Against You
Product in Wartime: How to Build When the Market Is Against YouProduct in Wartime: How to Build When the Market Is Against You
Product in Wartime: How to Build When the Market Is Against You
victoriamangiantini1
 
NS3 Unit 5 Matter changes presentation.pptx
NS3 Unit 5 Matter changes presentation.pptxNS3 Unit 5 Matter changes presentation.pptx
NS3 Unit 5 Matter changes presentation.pptx
manuelaromero2013
 
Letter to Secretary Linda McMahon from U.S. Senators
Letter to Secretary Linda McMahon from U.S. SenatorsLetter to Secretary Linda McMahon from U.S. Senators
Letter to Secretary Linda McMahon from U.S. Senators
Mebane Rash
 
How to Manage Customer Info from POS in Odoo 18
How to Manage Customer Info from POS in Odoo 18How to Manage Customer Info from POS in Odoo 18
How to Manage Customer Info from POS in Odoo 18
Celine George
 
NS3 Unit 5 Energy presentation 2025.pptx
NS3 Unit 5 Energy presentation 2025.pptxNS3 Unit 5 Energy presentation 2025.pptx
NS3 Unit 5 Energy presentation 2025.pptx
manuelaromero2013
 
Decision Tree-ID3,C4.5,CART,Regression Tree
Decision Tree-ID3,C4.5,CART,Regression TreeDecision Tree-ID3,C4.5,CART,Regression Tree
Decision Tree-ID3,C4.5,CART,Regression Tree
Global Academy of Technology
 
From Building Products to Owning the Business
From Building Products to Owning the BusinessFrom Building Products to Owning the Business
From Building Products to Owning the Business
victoriamangiantini1
 
Online elections for Parliament for European Union
Online elections for Parliament for European UnionOnline elections for Parliament for European Union
Online elections for Parliament for European Union
Monica Enache
 
CANSA World No Tobacco Day campaign 2025 Vaping is not a safe form of smoking...
CANSA World No Tobacco Day campaign 2025 Vaping is not a safe form of smoking...CANSA World No Tobacco Day campaign 2025 Vaping is not a safe form of smoking...
CANSA World No Tobacco Day campaign 2025 Vaping is not a safe form of smoking...
CANSA The Cancer Association of South Africa
 
The Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdfThe Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdf
Mirza Gazanfar Ali Baig
 
Automated Actions (Automation) in the Odoo 18
Automated Actions (Automation) in the Odoo 18Automated Actions (Automation) in the Odoo 18
Automated Actions (Automation) in the Odoo 18
Celine George
 
From Hype to Moat: Building a Defensible AI Strategy
From Hype to Moat: Building a Defensible AI StrategyFrom Hype to Moat: Building a Defensible AI Strategy
From Hype to Moat: Building a Defensible AI Strategy
victoriamangiantini1
 
The Pedagogy We Practice: Best Practices for Critical Instructional Design
The Pedagogy We Practice: Best Practices for Critical Instructional DesignThe Pedagogy We Practice: Best Practices for Critical Instructional Design
The Pedagogy We Practice: Best Practices for Critical Instructional Design
Sean Michael Morris
 
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup
 
AI and international projects. Helsinki 20.5.25
AI and international projects. Helsinki 20.5.25AI and international projects. Helsinki 20.5.25
AI and international projects. Helsinki 20.5.25
Matleena Laakso
 
How to Automate Activities Using Odoo 18 CRM
How to Automate Activities Using Odoo 18 CRMHow to Automate Activities Using Odoo 18 CRM
How to Automate Activities Using Odoo 18 CRM
Celine George
 
Management of head injury in children.pdf
Management of head injury in children.pdfManagement of head injury in children.pdf
Management of head injury in children.pdf
sachin7989
 
NA FASE REGIONAL DO TL – 1.º CICLO. .
NA FASE REGIONAL DO TL – 1.º CICLO.     .NA FASE REGIONAL DO TL – 1.º CICLO.     .
NA FASE REGIONAL DO TL – 1.º CICLO. .
Colégio Santa Teresinha
 
he Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Successhe Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Success
TechSoup
 
Intervene with Precision: Zooming In as a Leader Without Micromanaging
Intervene with Precision: Zooming In as a Leader Without MicromanagingIntervene with Precision: Zooming In as a Leader Without Micromanaging
Intervene with Precision: Zooming In as a Leader Without Micromanaging
victoriamangiantini1
 
Product in Wartime: How to Build When the Market Is Against You
Product in Wartime: How to Build When the Market Is Against YouProduct in Wartime: How to Build When the Market Is Against You
Product in Wartime: How to Build When the Market Is Against You
victoriamangiantini1
 
NS3 Unit 5 Matter changes presentation.pptx
NS3 Unit 5 Matter changes presentation.pptxNS3 Unit 5 Matter changes presentation.pptx
NS3 Unit 5 Matter changes presentation.pptx
manuelaromero2013
 
Letter to Secretary Linda McMahon from U.S. Senators
Letter to Secretary Linda McMahon from U.S. SenatorsLetter to Secretary Linda McMahon from U.S. Senators
Letter to Secretary Linda McMahon from U.S. Senators
Mebane Rash
 
How to Manage Customer Info from POS in Odoo 18
How to Manage Customer Info from POS in Odoo 18How to Manage Customer Info from POS in Odoo 18
How to Manage Customer Info from POS in Odoo 18
Celine George
 
NS3 Unit 5 Energy presentation 2025.pptx
NS3 Unit 5 Energy presentation 2025.pptxNS3 Unit 5 Energy presentation 2025.pptx
NS3 Unit 5 Energy presentation 2025.pptx
manuelaromero2013
 
From Building Products to Owning the Business
From Building Products to Owning the BusinessFrom Building Products to Owning the Business
From Building Products to Owning the Business
victoriamangiantini1
 
Online elections for Parliament for European Union
Online elections for Parliament for European UnionOnline elections for Parliament for European Union
Online elections for Parliament for European Union
Monica Enache
 
The Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdfThe Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdf
Mirza Gazanfar Ali Baig
 
Automated Actions (Automation) in the Odoo 18
Automated Actions (Automation) in the Odoo 18Automated Actions (Automation) in the Odoo 18
Automated Actions (Automation) in the Odoo 18
Celine George
 
From Hype to Moat: Building a Defensible AI Strategy
From Hype to Moat: Building a Defensible AI StrategyFrom Hype to Moat: Building a Defensible AI Strategy
From Hype to Moat: Building a Defensible AI Strategy
victoriamangiantini1
 
The Pedagogy We Practice: Best Practices for Critical Instructional Design
The Pedagogy We Practice: Best Practices for Critical Instructional DesignThe Pedagogy We Practice: Best Practices for Critical Instructional Design
The Pedagogy We Practice: Best Practices for Critical Instructional Design
Sean Michael Morris
 
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup
 
AI and international projects. Helsinki 20.5.25
AI and international projects. Helsinki 20.5.25AI and international projects. Helsinki 20.5.25
AI and international projects. Helsinki 20.5.25
Matleena Laakso
 
How to Automate Activities Using Odoo 18 CRM
How to Automate Activities Using Odoo 18 CRMHow to Automate Activities Using Odoo 18 CRM
How to Automate Activities Using Odoo 18 CRM
Celine George
 
Management of head injury in children.pdf
Management of head injury in children.pdfManagement of head injury in children.pdf
Management of head injury in children.pdf
sachin7989
 
he Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Successhe Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Success
TechSoup
 

CSS Best practice

  • 3. “Best practice” is a very loose and often poorly defined term.
  • 4. “Best practice” often comes down to personal opinion.
  • 5. “Best practice” can depend on the team environment you are working in.
  • 6. “Best practice” may also depend on the applications you have to work with.
  • 7. Your personal “best practices” may change radically over time!
  • 8. With that in mind, here are some tips that may help you when setting up CSS files in the future.
  • 10. 1. Avoid using inline styles as they are hard to maintain and increase file size. Avoid <body> <h2 style=“color: red;”> ! Heading here </h2>
  • 11. 2. Avoid using header styles as they are also hard to maintain and increase file size. Avoid <style> p { color: red; } </style>
  • 12. 3. Avoid using @import within the HTML as this will slow down IE browsers. Avoid <style> @import "a.css"; </style>
  • 13. 4. Avoid using multiple CSS files, or combine all CSS files before final production. Avoid <link rel="stylesheet" href="reset.css"> <link rel="stylesheet" href="grids.css"> <link rel="stylesheet" href="text.css"> <link rel="stylesheet" href="modules.css"> <link rel="stylesheet" href="colors.css">
  • 15. 5. Use multiple declarations where possible p { ! margin: 0 0 1.5em; ! background: green; }
  • 16. 6. Use multiple selectors where possible h1, h2, h3, h4, h5 { ! color: #666; ! margin: 0 0 .5em; }
  • 17. 7. Use shorthand properties where possible body { Avoid margin-top: 20px; margin-right: 10px; margin-bottom: 20px; margin-left: 10px; } Preferred body { margin: 20px 10px; }
  • 18. 8. Avoid !important as it is often unnecessary - especially when you understand the cascade. p Avoid { ! margin: 0 !important; }
  • 19. 9. Avoid complex selectors (taxing for browsers). Try to be only as specific as needed. Avoid #navigation ul li a { margin: 0; } #navigation a { margin: 0; } Preferred
  • 20. 10. Avoid universal selectors. Avoid .nav * { margin: 0; }
  • 21. 11. Avoid qualifying selectors as this is often unnecessary. Avoid div.nav { } .nav { } Preferred
  • 22. 12. Avoid IE-proprietary filters as they slow page performance. Avoid filter:Alpha(Opacity=40); -ms-filter: "Alpha(Opacity=40)";
  • 23. 13. Avoid IDs. Where possible use classes instead. Avoid #header { ... } .header { ... } Preferred
  • 24. 14. Try not to use too many font-size declarations. h1 { font-size: 200%; } Avoid .nav { font-size: 80%; } .widget { font-size: 70%; } .intro { font-size: 110%; } .sidebar { font-size: 85%; }
  • 26. 15. Some people like to use a CSS minifier to reduce your overall CSS file size: http://refresh-sf.com/yui/
  • 27. 16. Optimise images as much as possible
  • 28. 17. Where possible, combine images into sprites.
  • 29. 18. If possible, use CSS3 rules instead of images to reduce server requests and page size. Avoid p { background: url(round-corners.png); } p { border-radius: 10px; } Preferred
  • 30. Russ Weakley Max Design Site: maxdesign.com.au Twitter: twitter.com/russmaxdesign Slideshare: slideshare.net/maxdesign Linkedin: linkedin.com/in/russweakley