SlideShare a Scribd company logo
How do speed up web pages? CSS & HTML tricks - Swati Arora
Some EASY tricks CSS font shorthand rule Two classes together CSS Sprites !important ignored by IE Image replacement technique Google web fonts Text Wrapping Cross browser Opacity
CSS font shorthand rule When styling fonts with CSS you may be doing this: font-size: 1em; line-height: 1.5em; font-weight: bold; font-style: italic; font-varient: small-caps; font-family: verdana,serif font: 1em/1.5em bold italic small-caps verdana,serif NOTE: This CSS shorthand version will only work if you're specifying both the font-size and the font-family else the font-weight, font-style, or font-varient then these values will automatically default to a value of normal.
Two classes together <p class=&quot;text pad&quot;>...</p> Using these two classes together (separated by a space, not with a comma) means that the paragraph calls up the rules assigned to both  text and pad.  If any rules overlap between the two classes then the class which  is below the other in the CSS document will take precedence.
CSS Sprites BELOW #nav li a {background:none no-repeat left center} #nav li a.item1 {background-image:url('../img/image1.gif')} #nav li a:hover.item1 {background-image:url('../img/image1_over.gif')} #nav li a.item2 {background-image:url('../img/image2.gif')} #nav li a:hover.item2 {background-image:url('../img/image2_over.gif')} AFTER #nav li a {background-image:url('../img/image_nav.gif')} #nav li a.item1 {background-position:0px 0px} #nav li a:hover.item1 {background-position:0px -72px} #nav li a.item2 {background-position:0px -143px;} #nav li a:hover.item2 {background-position:0px -215px;}
CSS Sprites - Buttons HTML <div class=&quot;clearbutton&quot;> <a class=&quot;GlobalOrangeButton&quot; href=&quot;#&quot;><span>So Neat!</span></a> </div> CSS a.GlobalOrangeButton span { background: transparent url('images/button_left_orange.png') no-repeat 0 0; display: block; line-height: 22px; padding: 7px 0 5px 18px; color: #fff; } a.GlobalOrangeButton { background: transparent url('images/button_right_orange.png') no-repeat top right; display: block; float: left; height: 34px; margin-right: 6px; padding-right: 20px; text-decoration: none; font-family: Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; } a.GlobalOrangeButton:hover span { background-position: 0 -34px; color: #fff; } a.GlobalOrangeButton:hover { background-position: right -34px; }
!important ignored by IE Normally in CSS whichever rule is specified last takes precedence. However if you use  !important  after a command then this CSS command will take precedence regardless of what appears after it. This is true for all browsers except IE. An example of this would be: margin-top: 3.5em !important; margin-top: 2em So, the top margin will be set to 3.5em for all browsers except IE, which will have a top  margin of 2em. This can sometimes come in useful, especially when using relative margins  (such as in this example) as these can display slightly differently between IE and other  browsers.
Google Web Fonts The Google Font API helps you add web fonts to any web page. Benefits of the Google Font API include: A choice of high quality open source fonts. Works in most browsers. Extremely easy to use. For example, the following text uses a web font called Tangerine: <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://fonts.googleapis.com/css?family=Tangerine&quot;> <style> body { font-family: 'Tangerine', serif; font-size: 48px;   text-shadow: 4px 4px 4px #aaa;}  </style> Making the Web Beautiful!
Text Wrapping .truncate { width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } A long cold winter delayed the blossoming of the millions of cherry...
.transparent_class { /* IE 8 */ -ms-filter: &quot;progid:DXImageTransform.Microsoft.Alpha(Opacity=50)&quot;; /* IE 5-7 */ filter: alpha(opacity=50); /* Netscape */ -moz-opacity: 0.5; /* Safari 1.x */ -khtml-opacity: 0.5; /* Good browsers */ opacity: 0.5; } Cross Browser Opacity
Intro to HTML 5
Benefits of HTML 5 Less Header codes More semantic HTML tags Media Tags Geolocation Canvas Input Types Form validation Draggable Local Storage Cross Domain Messaging
Intro to HTML 5 The new structural elements <header> <nav> <section> <article> <aside> <footer>
Lets check this
 

More Related Content

What's hot (20)

ElggCamp Santiago - Dev Edition
ElggCamp Santiago - Dev EditionElggCamp Santiago - Dev Edition
ElggCamp Santiago - Dev Edition
Brett Profitt
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
Yi-Ting Cheng
 
Coder Presentation Boston
Coder Presentation BostonCoder Presentation Boston
Coder Presentation Boston
Doug Green
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
RORLAB
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
Ben Mabey
 
Djangoアプリのデプロイに関するプラクティス / Deploy django application
Djangoアプリのデプロイに関するプラクティス / Deploy django applicationDjangoアプリのデプロイに関するプラクティス / Deploy django application
Djangoアプリのデプロイに関するプラクティス / Deploy django application
Masashi Shibata
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
Ronald Huereca
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
BG Java EE Course
 
Web-Performance
Web-PerformanceWeb-Performance
Web-Performance
Walter Ebert
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
ทวิร พานิชสมบัติ
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third Plugin
Justin Ryan
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggets
guestbd1cdca
 
Joomla Day UK 2009 Template Design Presentation
Joomla Day UK 2009 Template Design PresentationJoomla Day UK 2009 Template Design Presentation
Joomla Day UK 2009 Template Design Presentation
Chris Davenport
 
Joomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template DesignJoomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template Design
Andy Wallace
 
All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...
Caelum
 
Intro to html5 Boilerplate
Intro to html5 BoilerplateIntro to html5 Boilerplate
Intro to html5 Boilerplate
Michael Enslow
 
Introduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC FrameworksIntroduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC Frameworks
Gerald Krishnan
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008
Volkan Unsal
 
ElggCamp Santiago - Dev Edition
ElggCamp Santiago - Dev EditionElggCamp Santiago - Dev Edition
ElggCamp Santiago - Dev Edition
Brett Profitt
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
Yi-Ting Cheng
 
Coder Presentation Boston
Coder Presentation BostonCoder Presentation Boston
Coder Presentation Boston
Doug Green
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
RORLAB
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
Ben Mabey
 
Djangoアプリのデプロイに関するプラクティス / Deploy django application
Djangoアプリのデプロイに関するプラクティス / Deploy django applicationDjangoアプリのデプロイに関するプラクティス / Deploy django application
Djangoアプリのデプロイに関するプラクティス / Deploy django application
Masashi Shibata
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third Plugin
Justin Ryan
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggets
guestbd1cdca
 
Joomla Day UK 2009 Template Design Presentation
Joomla Day UK 2009 Template Design PresentationJoomla Day UK 2009 Template Design Presentation
Joomla Day UK 2009 Template Design Presentation
Chris Davenport
 
Joomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template DesignJoomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template Design
Andy Wallace
 
All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...
Caelum
 
Intro to html5 Boilerplate
Intro to html5 BoilerplateIntro to html5 Boilerplate
Intro to html5 Boilerplate
Michael Enslow
 
Introduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC FrameworksIntroduction to Using PHP & MVC Frameworks
Introduction to Using PHP & MVC Frameworks
Gerald Krishnan
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008
Volkan Unsal
 

Similar to How do speed up web pages? CSS & HTML Tricks (20)

Html Expression Web
Html Expression WebHtml Expression Web
Html Expression Web
Mark Frydenberg
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
Hatem Mahmoud
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webgl
Kilian Valkhof
 
CSS
CSSCSS
CSS
anandha ganesh
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
sanjay2211
 
CSS Fundamentals
CSS FundamentalsCSS Fundamentals
CSS Fundamentals
Ray Villalobos
 
Css
CssCss
Css
MAGNA COLLEGE OF ENGINEERING
 
Stylesheets for Online Help - Scott DeLoach, ClickStart
Stylesheets for Online Help - Scott DeLoach, ClickStartStylesheets for Online Help - Scott DeLoach, ClickStart
Stylesheets for Online Help - Scott DeLoach, ClickStart
Scott DeLoach
 
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
Brendan Sera-Shriar
 
css.ppt
css.pptcss.ppt
css.ppt
DakshPratapSingh1
 
css.ppt
css.pptcss.ppt
css.ppt
Sana903754
 
HTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.pptHTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.ppt
raghavanp4
 
Even faster web sites presentation 3
Even faster web sites presentation 3Even faster web sites presentation 3
Even faster web sites presentation 3
Felipe Lavín
 
User Defined Characters Solution Proposal
User Defined Characters Solution ProposalUser Defined Characters Solution Proposal
User Defined Characters Solution Proposal
Jun Fujisawa
 
What I brought back from Austin
What I brought back from AustinWhat I brought back from Austin
What I brought back from Austin
Lisa Adkins
 
Css3 101
Css3 101Css3 101
Css3 101
Ignacio Coloma
 
Implementing @font-face
Implementing @font-faceImplementing @font-face
Implementing @font-face
Aban Nesta
 
Svg Overview And Js Libraries
Svg Overview And Js LibrariesSvg Overview And Js Libraries
Svg Overview And Js Libraries
seamusjr
 
Visualforce css developer guide(by forcetree.com)
Visualforce css developer guide(by forcetree.com)Visualforce css developer guide(by forcetree.com)
Visualforce css developer guide(by forcetree.com)
Edwin Vijay R
 
Web 2.0 Lessonplan Day1
Web 2.0 Lessonplan Day1Web 2.0 Lessonplan Day1
Web 2.0 Lessonplan Day1
Jesse Thomas
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
Hatem Mahmoud
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webgl
Kilian Valkhof
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
sanjay2211
 
Stylesheets for Online Help - Scott DeLoach, ClickStart
Stylesheets for Online Help - Scott DeLoach, ClickStartStylesheets for Online Help - Scott DeLoach, ClickStart
Stylesheets for Online Help - Scott DeLoach, ClickStart
Scott DeLoach
 
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
Brendan Sera-Shriar
 
HTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.pptHTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.ppt
raghavanp4
 
Even faster web sites presentation 3
Even faster web sites presentation 3Even faster web sites presentation 3
Even faster web sites presentation 3
Felipe Lavín
 
User Defined Characters Solution Proposal
User Defined Characters Solution ProposalUser Defined Characters Solution Proposal
User Defined Characters Solution Proposal
Jun Fujisawa
 
What I brought back from Austin
What I brought back from AustinWhat I brought back from Austin
What I brought back from Austin
Lisa Adkins
 
Implementing @font-face
Implementing @font-faceImplementing @font-face
Implementing @font-face
Aban Nesta
 
Svg Overview And Js Libraries
Svg Overview And Js LibrariesSvg Overview And Js Libraries
Svg Overview And Js Libraries
seamusjr
 
Visualforce css developer guide(by forcetree.com)
Visualforce css developer guide(by forcetree.com)Visualforce css developer guide(by forcetree.com)
Visualforce css developer guide(by forcetree.com)
Edwin Vijay R
 
Web 2.0 Lessonplan Day1
Web 2.0 Lessonplan Day1Web 2.0 Lessonplan Day1
Web 2.0 Lessonplan Day1
Jesse Thomas
 

More from Compare Infobase Limited (20)

Google +
Google +Google +
Google +
Compare Infobase Limited
 
J Query
J QueryJ Query
J Query
Compare Infobase Limited
 
Dos and Don't during Monsoon!
Dos and Don't during Monsoon!Dos and Don't during Monsoon!
Dos and Don't during Monsoon!
Compare Infobase Limited
 
Intellectual Property Rights : A Primer
Intellectual Property Rights : A PrimerIntellectual Property Rights : A Primer
Intellectual Property Rights : A Primer
Compare Infobase Limited
 
CIL initiative against Corruption
CIL initiative against CorruptionCIL initiative against Corruption
CIL initiative against Corruption
Compare Infobase Limited
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
Compare Infobase Limited
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
Compare Infobase Limited
 
Storage and Storage Devices
Storage and Storage DevicesStorage and Storage Devices
Storage and Storage Devices
Compare Infobase Limited
 
SQL Injection Attacks
SQL Injection AttacksSQL Injection Attacks
SQL Injection Attacks
Compare Infobase Limited
 
World No Tobacco Day
World No Tobacco DayWorld No Tobacco Day
World No Tobacco Day
Compare Infobase Limited
 
Tips for Effective Online Marketing
Tips for Effective Online Marketing Tips for Effective Online Marketing
Tips for Effective Online Marketing
Compare Infobase Limited
 
iOS Application Development
iOS Application DevelopmentiOS Application Development
iOS Application Development
Compare Infobase Limited
 
Have a safe Summer!
Have a safe Summer!Have a safe Summer!
Have a safe Summer!
Compare Infobase Limited
 
Introduction to Android Environment
Introduction to Android EnvironmentIntroduction to Android Environment
Introduction to Android Environment
Compare Infobase Limited
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
Compare Infobase Limited
 
Software Development Life Cycle Part II
Software Development Life Cycle Part IISoftware Development Life Cycle Part II
Software Development Life Cycle Part II
Compare Infobase Limited
 
Excel with Excel
Excel with ExcelExcel with Excel
Excel with Excel
Compare Infobase Limited
 
Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)
Compare Infobase Limited
 
How to increase effective CTR, CPC and e CPM of website?
How to increase effective CTR, CPC and e CPM of website?How to increase effective CTR, CPC and e CPM of website?
How to increase effective CTR, CPC and e CPM of website?
Compare Infobase Limited
 
Social Media Integration
Social Media IntegrationSocial Media Integration
Social Media Integration
Compare Infobase Limited
 
How to increase effective CTR, CPC and e CPM of website?
How to increase effective CTR, CPC and e CPM of website?How to increase effective CTR, CPC and e CPM of website?
How to increase effective CTR, CPC and e CPM of website?
Compare Infobase Limited
 

How do speed up web pages? CSS & HTML Tricks

  • 1. How do speed up web pages? CSS & HTML tricks - Swati Arora
  • 2. Some EASY tricks CSS font shorthand rule Two classes together CSS Sprites !important ignored by IE Image replacement technique Google web fonts Text Wrapping Cross browser Opacity
  • 3. CSS font shorthand rule When styling fonts with CSS you may be doing this: font-size: 1em; line-height: 1.5em; font-weight: bold; font-style: italic; font-varient: small-caps; font-family: verdana,serif font: 1em/1.5em bold italic small-caps verdana,serif NOTE: This CSS shorthand version will only work if you're specifying both the font-size and the font-family else the font-weight, font-style, or font-varient then these values will automatically default to a value of normal.
  • 4. Two classes together <p class=&quot;text pad&quot;>...</p> Using these two classes together (separated by a space, not with a comma) means that the paragraph calls up the rules assigned to both text and pad. If any rules overlap between the two classes then the class which is below the other in the CSS document will take precedence.
  • 5. CSS Sprites BELOW #nav li a {background:none no-repeat left center} #nav li a.item1 {background-image:url('../img/image1.gif')} #nav li a:hover.item1 {background-image:url('../img/image1_over.gif')} #nav li a.item2 {background-image:url('../img/image2.gif')} #nav li a:hover.item2 {background-image:url('../img/image2_over.gif')} AFTER #nav li a {background-image:url('../img/image_nav.gif')} #nav li a.item1 {background-position:0px 0px} #nav li a:hover.item1 {background-position:0px -72px} #nav li a.item2 {background-position:0px -143px;} #nav li a:hover.item2 {background-position:0px -215px;}
  • 6. CSS Sprites - Buttons HTML <div class=&quot;clearbutton&quot;> <a class=&quot;GlobalOrangeButton&quot; href=&quot;#&quot;><span>So Neat!</span></a> </div> CSS a.GlobalOrangeButton span { background: transparent url('images/button_left_orange.png') no-repeat 0 0; display: block; line-height: 22px; padding: 7px 0 5px 18px; color: #fff; } a.GlobalOrangeButton { background: transparent url('images/button_right_orange.png') no-repeat top right; display: block; float: left; height: 34px; margin-right: 6px; padding-right: 20px; text-decoration: none; font-family: Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; } a.GlobalOrangeButton:hover span { background-position: 0 -34px; color: #fff; } a.GlobalOrangeButton:hover { background-position: right -34px; }
  • 7. !important ignored by IE Normally in CSS whichever rule is specified last takes precedence. However if you use !important after a command then this CSS command will take precedence regardless of what appears after it. This is true for all browsers except IE. An example of this would be: margin-top: 3.5em !important; margin-top: 2em So, the top margin will be set to 3.5em for all browsers except IE, which will have a top margin of 2em. This can sometimes come in useful, especially when using relative margins (such as in this example) as these can display slightly differently between IE and other browsers.
  • 8. Google Web Fonts The Google Font API helps you add web fonts to any web page. Benefits of the Google Font API include: A choice of high quality open source fonts. Works in most browsers. Extremely easy to use. For example, the following text uses a web font called Tangerine: <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://fonts.googleapis.com/css?family=Tangerine&quot;> <style> body { font-family: 'Tangerine', serif; font-size: 48px; text-shadow: 4px 4px 4px #aaa;} </style> Making the Web Beautiful!
  • 9. Text Wrapping .truncate { width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } A long cold winter delayed the blossoming of the millions of cherry...
  • 10. .transparent_class { /* IE 8 */ -ms-filter: &quot;progid:DXImageTransform.Microsoft.Alpha(Opacity=50)&quot;; /* IE 5-7 */ filter: alpha(opacity=50); /* Netscape */ -moz-opacity: 0.5; /* Safari 1.x */ -khtml-opacity: 0.5; /* Good browsers */ opacity: 0.5; } Cross Browser Opacity
  • 12. Benefits of HTML 5 Less Header codes More semantic HTML tags Media Tags Geolocation Canvas Input Types Form validation Draggable Local Storage Cross Domain Messaging
  • 13. Intro to HTML 5 The new structural elements <header> <nav> <section> <article> <aside> <footer>
  • 15.