SlideShare a Scribd company logo
By: Vijayta Panchal Vinayak Solutions
Introduction Cascading Style Sheets (CSS)  are a collection of formatting rules that control the appearance of content in a web page. They are very useful for maintaining a web site since its appearance (controlled by properties of HTML tags) can be managed from just one file.  CSS Styles  also enhance your site's look, accessibility and reduces file size. Another main advantage is  reusability  - instead of defining the properties of fonts, backgrounds, borders, bullets, uniform tags, etc. each time you use them you can just assign the corresponding css style in the  class property . You can store CSS styles directly in each document or, for more control and flexibility, in an external style sheet. Vinayak Solutions
Box Model What is the CSS Box Model: The CSS box model describes the boxes that are formed around elements of content in a Web page. Every element in a Web page is in a box or is a box, even if it's an image of a circle. The boxes on Web pages are constrained by rules defined by the box model.  Vinayak Solutions
The CSS box model is made up of four parts:  margin  border  padding  content  Vinayak Solutions
The  margin  is the outermost edge of the box. It is transparent and manifests as space between the element and others on the page. Margins can collapse into one another, so that the bottom margin of one element overlaps with the top margin of the element below it. The  border  is the next thing surrounding the box. Borders can be colored or transparent. If the border is set to 0 it effectively disappears and the border edge is the same as the padding edge. The  padding  is the space between the content and the border. Padding is the same color as the background color for the box. If the padding is set to 0, the padding border is the same as the content border. The  content  is what most people think of as the element. This is the text or image or whatever is displayed inside the box. Vinayak Solutions Continue…
Box Model Issues The problem with the CSS box model is that not all Web browsers implement it the same way. In a nutshell, according to the W3C, width and height properties define the width and height of the content of the box. Items like padding, border, and margin surround that width and height.  Some versions of Internet Explorer instead define the width and height as the width and height of the entire element, including padding, and border.  If you want your designs to look the same in all browsers, you have to employ tricks and sometimes hacks to get IE to work correctly.  Vinayak Solutions
Box Model Issues Vinayak Solutions
Styling List (CSS navigation) HTML Code <div id=”navigation”> <ul>   <li><a href=“home”>Home</a></li> <li><a href=“News”>News</a></li>  <li><a href=“how”>How to Work</a></li>  <li><a href=“about”>Aout Us</a></li>  </ul> </div> Vinayak Solutions CSS Code #navigation ul { margin-left:0; } #navigation ul li { display:inline; list-type-style:none; margin:0; text-align:left; } #navigation ul li a #home { background: url(”images/btn_home.png”) no-repeat scroll left center; height:28px; width:70px; float:left; text-indent:-2000px; } #navigation ul li a:hover #home { background: url(”images/btn_home.png”) no-repeat scroll right center; height:28px; width:70px; float:left; text-indent:-2000px; }
Vinayak Solutions Output is
CSS button You can make one of those orange XML or RSS buttons or icons without using an image with CSS. Here's how:   CSS:  .feed { border:1px solid; border-color:#FC9 #630 #330 #F96;  padding:0 3px; font: bold 10px verdana , sans-serif ;  color:#FFF;background:#F60;text-decoration:none; margin:4px; } HTML: <a href=&quot;/rss/&quot; class=&quot;feed&quot;>FEED</a> Vinayak Solutions
Rounded corner without images Thought CSS3 we can have rounded corner  box without using a single image. Vinayak Solutions
Vinayak Solutions <html> <head>   <style>   #container p{background:red; padding:none; margin:0; width:100px} .rtop, .rbottom{display:block} .rtop *, .rbottom *{display: block; height: 1px; overflow: hidden; } .r1{margin: 0 5px; background:#999;} .r2{margin: 0 3px; background:#999;} .r3{margin: 0 2px; background:#999;} .r4{margin: 0 1px; height: 2px; background:#999;}   </style> </head> <body> <div id=&quot;container&quot;> <b class=&quot;rtop&quot;> <b class=&quot;r1&quot;></b> <b class=&quot;r2&quot;></b> <b class=&quot;r3&quot;></b> <b class=&quot;r4&quot;></b> </b> <p>Your Test Goes Here.</p> <b class=&quot;rbottom&quot;> <b class=&quot;r4&quot;></b> <b class=&quot;r3&quot;></b> <b class=&quot;r2&quot;></b> <b class=&quot;r1&quot;></b> </b> </div> </body> </html>
Working with divs The <div> tag was designed specifically to take over from tables as a layout tool. It is a block-level DIVsion element that can hold whatever you need inside it. You can have  blocks  of text in divs and then put them together in a layout. You have immense freedom, with the ability to add these blocks, or layers, on top of each other. div#navigation  {width: 200px; background: gray; padding: 10px; } Vinayak Solutions
Float  Since divisions are block-level (i.e. they default to 100% of the available screen width and add line breaks between each other), they will all just stack up underneath one another unless you position them in some way. The simplest way to do this is to use the CSS  float  property, the backbone of most CSS layouts. You can float any element left or right, and it will align itself over to the side of whatever element it is contained within. With these floating elements you can mimic a table structure, and have your page in a traditional layout without all the drawbacks of tables. But CSS wasn't content to merely emulate the layout mechanisms of the past, now you can control the position of elements on the page down to the pixel. Vinayak Solutions
Clear Image and text elements that appear in another element are called floating elements. The clear property sets the sides of an element where other floating elements are not allowed. Values are Left Right none Vinayak Solutions
Tableless designs DIVs can be an alternate to  <table> DIVs are a container like a table cell CSS can position the DIV <div id=&quot;article&quot;>xxx</div> #article{ width:250px; padding:5px; float:right;}  Example of flexible tableless Design Vinayak Solutions
CSS Hacks The main problem with using CSS has been a lack of browser support. The problem is that sometimes browsers can interpret CSS commands in different ways. A hack is a method of exploiting the way a web browser processes ( parses ) CSS instructions ( rules ), to control the styles a webpage receives (and in turn, the design of the page). ‘Control’ includes the ability to hide or change rules based on the browser type and/or version. Vinayak Solutions
Some Important hacks IE 6 and below  * html {}  IE 7 and below  *:first-child+html {} * html {}  IE 7 only  *:first-child+html {}  IE 7 and modern browsers only  html>body {} Modern browsers only (not IE 7)  html>/**/body {}  Recent Opera versions 9 and below  html:first-child {} Vinayak Solutions Continue…
!important 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. Vinayak Solutions
CSS box model hack The box model hack is used to fix a rendering problem in pre-IE 6 browsers, where by the border and padding are  included  in the width of an element, as opposed to  added on . For example, when specifying the dimensions of a container you might use the following CSS rule: Vinayak Solutions #box { width: 150px; } #box div { border: 5px; padding: 20px; } #box { width: 100px; border: 5px; padding: 20px; } Code with Hack Regular  Code
@import &quot;non-ie.css&quot; all; Internet Explorer 7 and below don't support media selectors on @import rules, instead ignoring the entire rule when they are present. Therefore, you can create an entire stylesheet for non-IE browsers and import it into your main stylesheet by adding @import &quot;non-ie.css&quot; all;. Future versions of Internet Explorer may support the @import rule correctly. @import &quot; stylesheet.css &quot; all; Vinayak Solutions
Grouping styles You can give the same properties to a number of selectors without having to repeat them by separating the selectors by  commas . It is a useful thing for reducing file size. Example Vinayak Solutions h2  {  color: red; } .thisOtherClass { color: red;  } .yetAnotherClass  { color: red; } h2, .thisOtherClass, .yetAnotherClass  { color: red;  } Normal CSS Grouped CSS h1, h2, h3, h4, h5, h6  { color: blue; }
Nested Styles If the CSS is structured well, there shouldn't be a need to use many class or ID selectors. This is because you can specify properties to selectors  within  other selectors. Vinayak Solutions #top  { background-color: #ccc; padding: 1em } # top h1 { color: #ff0; }  # top p  { color: red; font-weight: bold; }
Conditional CSS a[href $='.pdf'] {     padding-right: 18px;    background: transparent url(icon_pdf.gif) no-repeat center right; } This would attach a pdf icon to the right of any hyperlink who's URL ended in '.pdf' like this. This was pretty exciting and heady stuff. It meant I could show the file type visually with that application's icon just by including a few lines in my master css file. I didn't have to worry about it at all in my html, css would add the icon for me automatically. Vinayak Solutions
Another Example span[id ^='google'] {     background-color: green; } Any span which has an id which starts with 'google' will be assigned a green background. More Examples Vinayak Solutions
Conditional CSS .ie .example { background-color: yellow } .gecko .example { background-color: gray } .opera .example { background-color: green } .konqueror .example { background-color: blue } .webkit .example { background-color: black } .example { width: 100px; height: 100px; background-color: brown; } Vinayak Solutions
Vinayak Solutions Continued…
Validation Validate your HTML validator.w3.org  Validate your CSS jigsaw.w3.org/css-validator/   Check for web accessibility bobby.watchfire.com Vinayak Solutions
Overview of XHTML “ The Extensible HyperText Markup Language (XHTML™) is a family of current and future document types and modules that reproduce, subset, and extend HTML, reformulated in XML. XHTML Family document types are all XML-based, and ultimately are designed to work in conjunction with XML-based user agents. XHTML is the successor of HTML, and a series of specifications has been developed for XHTML.”  Vinayak Solutions
How do I convert to XHTML?” Declare the  DOCTYPE Tag and attributes in lower case Attributes must have quoted values  All tags must have an end tag  ( <br /> ) Nest tags correctly  Validate the page  (http://validator.w3.org) Vinayak Solutions
Benefits to XHTML More Accessible Eliminates silly mistakes in code Renders more accurately in browsers Backward AND forward compatible First step toward Web Standards Vinayak Solutions
Vinayak Solutions

More Related Content

What's hot (19)

PDF
Slicing the web
Mohamad Hemmat
 
PPTX
Html & CSS
JainilSampat
 
PDF
CSS Refresher
Gerson Abesamis
 
PDF
CSS For Backend Developers
10Clouds
 
PPTX
Css intro
Andz Bass
 
PDF
6 Steps to Make Your CSS Code More Maintainable
10Clouds
 
PDF
Styling Your Web Pages with Cascading Style Sheets / EDU course / University ...
Patrick Lauke
 
PPTX
Introduction to HTML and CSS
danpaquette
 
PDF
Intro to HTML & CSS
Syed Sami
 
PPTX
Div Tag Tutorial
bav123
 
PDF
An Intro to HTML & CSS
Shay Howe
 
PPTX
Visualforce css developer guide(by forcetree.com)
Edwin Vijay R
 
PPT
CSS Best practices
José Teixidó
 
PPTX
Css Basics
Jay Patel
 
PPTX
Customizing the Appearance and HTML Output of Visualforce Pages
Mohammed Safwat Abu Kwaik
 
PDF
Modular HTML, CSS, & JS Workshop
Shay Howe
 
PPTX
Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)
Tom Hapgood
 
Slicing the web
Mohamad Hemmat
 
Html & CSS
JainilSampat
 
CSS Refresher
Gerson Abesamis
 
CSS For Backend Developers
10Clouds
 
Css intro
Andz Bass
 
6 Steps to Make Your CSS Code More Maintainable
10Clouds
 
Styling Your Web Pages with Cascading Style Sheets / EDU course / University ...
Patrick Lauke
 
Introduction to HTML and CSS
danpaquette
 
Intro to HTML & CSS
Syed Sami
 
Div Tag Tutorial
bav123
 
An Intro to HTML & CSS
Shay Howe
 
Visualforce css developer guide(by forcetree.com)
Edwin Vijay R
 
CSS Best practices
José Teixidó
 
Css Basics
Jay Patel
 
Customizing the Appearance and HTML Output of Visualforce Pages
Mohammed Safwat Abu Kwaik
 
Modular HTML, CSS, & JS Workshop
Shay Howe
 
Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)
Tom Hapgood
 

Similar to Advance Css (20)

PPT
Using a CSS Framework
Gareth Saunders
 
PPT
CSS 101
dunclair
 
PDF
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 
PPT
CSS Methodology
Zohar Arad
 
PPT
Css
NIRMAL FELIX
 
PPT
Basics Of Css And Some Common Mistakes
sanjay2211
 
PPT
Making Your Site Look Great in IE7
goodfriday
 
PPT
Web Designing Bugs - Fixes By Nyros Developer
Nyros Technologies
 
ODP
Creating Web Sites with HTML and CSS
BG Java EE Course
 
PDF
Organize Your Website With Advanced CSS Tricks
Andolasoft Inc
 
KEY
Slow kinda sucks
Tim Wright
 
PDF
Structuring your CSS for maintainability: rules and guile lines to write CSS
Sanjoy Kr. Paul
 
PDF
Pfnp slides
William Myers
 
PPTX
Lecture-7.pptx
vishal choudhary
 
PPT
Even faster web sites presentation 3
Felipe Lavín
 
PDF
The CSS Handbook
jackchenvlo
 
PDF
The Future State of Layout
Stephen Hay
 
PPT
Web design-workflow
Peter Kaizer
 
Using a CSS Framework
Gareth Saunders
 
CSS 101
dunclair
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 
CSS Methodology
Zohar Arad
 
Basics Of Css And Some Common Mistakes
sanjay2211
 
Making Your Site Look Great in IE7
goodfriday
 
Web Designing Bugs - Fixes By Nyros Developer
Nyros Technologies
 
Creating Web Sites with HTML and CSS
BG Java EE Course
 
Organize Your Website With Advanced CSS Tricks
Andolasoft Inc
 
Slow kinda sucks
Tim Wright
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Sanjoy Kr. Paul
 
Pfnp slides
William Myers
 
Lecture-7.pptx
vishal choudhary
 
Even faster web sites presentation 3
Felipe Lavín
 
The CSS Handbook
jackchenvlo
 
The Future State of Layout
Stephen Hay
 
Web design-workflow
Peter Kaizer
 
Ad

Recently uploaded (20)

PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Python basic programing language for automation
DanialHabibi2
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
July Patch Tuesday
Ivanti
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Ad

Advance Css

  • 1. By: Vijayta Panchal Vinayak Solutions
  • 2. Introduction Cascading Style Sheets (CSS) are a collection of formatting rules that control the appearance of content in a web page. They are very useful for maintaining a web site since its appearance (controlled by properties of HTML tags) can be managed from just one file. CSS Styles also enhance your site's look, accessibility and reduces file size. Another main advantage is reusability - instead of defining the properties of fonts, backgrounds, borders, bullets, uniform tags, etc. each time you use them you can just assign the corresponding css style in the class property . You can store CSS styles directly in each document or, for more control and flexibility, in an external style sheet. Vinayak Solutions
  • 3. Box Model What is the CSS Box Model: The CSS box model describes the boxes that are formed around elements of content in a Web page. Every element in a Web page is in a box or is a box, even if it's an image of a circle. The boxes on Web pages are constrained by rules defined by the box model. Vinayak Solutions
  • 4. The CSS box model is made up of four parts: margin border padding content Vinayak Solutions
  • 5. The margin is the outermost edge of the box. It is transparent and manifests as space between the element and others on the page. Margins can collapse into one another, so that the bottom margin of one element overlaps with the top margin of the element below it. The border is the next thing surrounding the box. Borders can be colored or transparent. If the border is set to 0 it effectively disappears and the border edge is the same as the padding edge. The padding is the space between the content and the border. Padding is the same color as the background color for the box. If the padding is set to 0, the padding border is the same as the content border. The content is what most people think of as the element. This is the text or image or whatever is displayed inside the box. Vinayak Solutions Continue…
  • 6. Box Model Issues The problem with the CSS box model is that not all Web browsers implement it the same way. In a nutshell, according to the W3C, width and height properties define the width and height of the content of the box. Items like padding, border, and margin surround that width and height. Some versions of Internet Explorer instead define the width and height as the width and height of the entire element, including padding, and border. If you want your designs to look the same in all browsers, you have to employ tricks and sometimes hacks to get IE to work correctly. Vinayak Solutions
  • 7. Box Model Issues Vinayak Solutions
  • 8. Styling List (CSS navigation) HTML Code <div id=”navigation”> <ul> <li><a href=“home”>Home</a></li> <li><a href=“News”>News</a></li> <li><a href=“how”>How to Work</a></li> <li><a href=“about”>Aout Us</a></li> </ul> </div> Vinayak Solutions CSS Code #navigation ul { margin-left:0; } #navigation ul li { display:inline; list-type-style:none; margin:0; text-align:left; } #navigation ul li a #home { background: url(”images/btn_home.png”) no-repeat scroll left center; height:28px; width:70px; float:left; text-indent:-2000px; } #navigation ul li a:hover #home { background: url(”images/btn_home.png”) no-repeat scroll right center; height:28px; width:70px; float:left; text-indent:-2000px; }
  • 10. CSS button You can make one of those orange XML or RSS buttons or icons without using an image with CSS. Here's how: CSS: .feed { border:1px solid; border-color:#FC9 #630 #330 #F96; padding:0 3px; font: bold 10px verdana , sans-serif ; color:#FFF;background:#F60;text-decoration:none; margin:4px; } HTML: <a href=&quot;/rss/&quot; class=&quot;feed&quot;>FEED</a> Vinayak Solutions
  • 11. Rounded corner without images Thought CSS3 we can have rounded corner box without using a single image. Vinayak Solutions
  • 12. Vinayak Solutions <html> <head> <style> #container p{background:red; padding:none; margin:0; width:100px} .rtop, .rbottom{display:block} .rtop *, .rbottom *{display: block; height: 1px; overflow: hidden; } .r1{margin: 0 5px; background:#999;} .r2{margin: 0 3px; background:#999;} .r3{margin: 0 2px; background:#999;} .r4{margin: 0 1px; height: 2px; background:#999;} </style> </head> <body> <div id=&quot;container&quot;> <b class=&quot;rtop&quot;> <b class=&quot;r1&quot;></b> <b class=&quot;r2&quot;></b> <b class=&quot;r3&quot;></b> <b class=&quot;r4&quot;></b> </b> <p>Your Test Goes Here.</p> <b class=&quot;rbottom&quot;> <b class=&quot;r4&quot;></b> <b class=&quot;r3&quot;></b> <b class=&quot;r2&quot;></b> <b class=&quot;r1&quot;></b> </b> </div> </body> </html>
  • 13. Working with divs The <div> tag was designed specifically to take over from tables as a layout tool. It is a block-level DIVsion element that can hold whatever you need inside it. You can have blocks of text in divs and then put them together in a layout. You have immense freedom, with the ability to add these blocks, or layers, on top of each other. div#navigation {width: 200px; background: gray; padding: 10px; } Vinayak Solutions
  • 14. Float Since divisions are block-level (i.e. they default to 100% of the available screen width and add line breaks between each other), they will all just stack up underneath one another unless you position them in some way. The simplest way to do this is to use the CSS float property, the backbone of most CSS layouts. You can float any element left or right, and it will align itself over to the side of whatever element it is contained within. With these floating elements you can mimic a table structure, and have your page in a traditional layout without all the drawbacks of tables. But CSS wasn't content to merely emulate the layout mechanisms of the past, now you can control the position of elements on the page down to the pixel. Vinayak Solutions
  • 15. Clear Image and text elements that appear in another element are called floating elements. The clear property sets the sides of an element where other floating elements are not allowed. Values are Left Right none Vinayak Solutions
  • 16. Tableless designs DIVs can be an alternate to <table> DIVs are a container like a table cell CSS can position the DIV <div id=&quot;article&quot;>xxx</div> #article{ width:250px; padding:5px; float:right;} Example of flexible tableless Design Vinayak Solutions
  • 17. CSS Hacks The main problem with using CSS has been a lack of browser support. The problem is that sometimes browsers can interpret CSS commands in different ways. A hack is a method of exploiting the way a web browser processes ( parses ) CSS instructions ( rules ), to control the styles a webpage receives (and in turn, the design of the page). ‘Control’ includes the ability to hide or change rules based on the browser type and/or version. Vinayak Solutions
  • 18. Some Important hacks IE 6 and below * html {} IE 7 and below *:first-child+html {} * html {} IE 7 only *:first-child+html {} IE 7 and modern browsers only html>body {} Modern browsers only (not IE 7) html>/**/body {} Recent Opera versions 9 and below html:first-child {} Vinayak Solutions Continue…
  • 19. !important 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. Vinayak Solutions
  • 20. CSS box model hack The box model hack is used to fix a rendering problem in pre-IE 6 browsers, where by the border and padding are included in the width of an element, as opposed to added on . For example, when specifying the dimensions of a container you might use the following CSS rule: Vinayak Solutions #box { width: 150px; } #box div { border: 5px; padding: 20px; } #box { width: 100px; border: 5px; padding: 20px; } Code with Hack Regular Code
  • 21. @import &quot;non-ie.css&quot; all; Internet Explorer 7 and below don't support media selectors on @import rules, instead ignoring the entire rule when they are present. Therefore, you can create an entire stylesheet for non-IE browsers and import it into your main stylesheet by adding @import &quot;non-ie.css&quot; all;. Future versions of Internet Explorer may support the @import rule correctly. @import &quot; stylesheet.css &quot; all; Vinayak Solutions
  • 22. Grouping styles You can give the same properties to a number of selectors without having to repeat them by separating the selectors by commas . It is a useful thing for reducing file size. Example Vinayak Solutions h2 { color: red; } .thisOtherClass { color: red; } .yetAnotherClass { color: red; } h2, .thisOtherClass, .yetAnotherClass { color: red; } Normal CSS Grouped CSS h1, h2, h3, h4, h5, h6 { color: blue; }
  • 23. Nested Styles If the CSS is structured well, there shouldn't be a need to use many class or ID selectors. This is because you can specify properties to selectors within other selectors. Vinayak Solutions #top { background-color: #ccc; padding: 1em } # top h1 { color: #ff0; } # top p { color: red; font-weight: bold; }
  • 24. Conditional CSS a[href $='.pdf'] {    padding-right: 18px;    background: transparent url(icon_pdf.gif) no-repeat center right; } This would attach a pdf icon to the right of any hyperlink who's URL ended in '.pdf' like this. This was pretty exciting and heady stuff. It meant I could show the file type visually with that application's icon just by including a few lines in my master css file. I didn't have to worry about it at all in my html, css would add the icon for me automatically. Vinayak Solutions
  • 25. Another Example span[id ^='google'] {    background-color: green; } Any span which has an id which starts with 'google' will be assigned a green background. More Examples Vinayak Solutions
  • 26. Conditional CSS .ie .example { background-color: yellow } .gecko .example { background-color: gray } .opera .example { background-color: green } .konqueror .example { background-color: blue } .webkit .example { background-color: black } .example { width: 100px; height: 100px; background-color: brown; } Vinayak Solutions
  • 28. Validation Validate your HTML validator.w3.org Validate your CSS jigsaw.w3.org/css-validator/ Check for web accessibility bobby.watchfire.com Vinayak Solutions
  • 29. Overview of XHTML “ The Extensible HyperText Markup Language (XHTML™) is a family of current and future document types and modules that reproduce, subset, and extend HTML, reformulated in XML. XHTML Family document types are all XML-based, and ultimately are designed to work in conjunction with XML-based user agents. XHTML is the successor of HTML, and a series of specifications has been developed for XHTML.” Vinayak Solutions
  • 30. How do I convert to XHTML?” Declare the DOCTYPE Tag and attributes in lower case Attributes must have quoted values All tags must have an end tag ( <br /> ) Nest tags correctly Validate the page (http://validator.w3.org) Vinayak Solutions
  • 31. Benefits to XHTML More Accessible Eliminates silly mistakes in code Renders more accurately in browsers Backward AND forward compatible First step toward Web Standards Vinayak Solutions