Contents at a Glance
Total Page:16
File Type:pdf, Size:1020Kb
02_579851 ftoc.qxd 5/4/05 11:05 PM Page ix Contents at a Glance Acknowledgments . xvii Introduction . xix Chapter 1:Why Hack CSS?. 1 Chapter 2:Filtering CSS for Older Browsers . 11 Chapter 3:Hiding CSS from Newer Browsers. 33 Chapter 4:Applying Conditional Comments . 57 Chapter 5:Scripting JavaScript and Document Object Model Hacks. 71 Chapter 6:Coding Server-Side Solutions . 87 Chapter 7:Enhancing Graphics and Media with CSS . 99 Chapter 8:Maintaining Accessibility with CSS . 121 Chapter 9:Integrated CSS Hack Layouts . 131 Chapter 10:Building Navigation Systems . 159 Chapter 11:Troubleshooting CSS . 177 Chapter 12:Implementing CSS Hacks in Dreamweaver. 191 Chapter 13:Creating CSS-Savvy Dreamweaver Templates . 219 Appendix A:Resources . 235 Appendix B:CSS Hacks and Filters Charts . 243 Index . 249 COPYRIGHTED MATERIAL 02_579851 ftoc.qxd 5/4/05 11:05 PM Page x 02_579851 ftoc.qxd 5/4/05 11:05 PM Page xi Contents Acknowledgments . xvii Introduction . xix Chapter 1: Why Hack CSS? . 1 The Cascading Style Sheets Promise . 1 Separate Presentation from Content. 2 Flexible Design Model. 2 Faster Loading Times . 3 Easy, Instant Maintenance . 3 Portability. 3 Advanced Design Possibilities . 3 Enhanced User Control . 4 Accessibility . 5 Why CSS Is Broken . 6 To Hack or Not to Hack . 8 Chapter 2: Filtering CSS for Older Browsers . 11 Hacking Netscape 4 . 11 Linking vs. Importing Style Sheets . 13 Hiding Individual Rules from Netscape 4 . 14 Dealing with Fonts Properly . 18 Adjusting Margins and Borders. 21 Working Through Background Problems. 23 Correcting List Issues. 25 Handling Table Discrepancies . 26 Fixing Internet Explorer 3 and 4 . 27 Hiding Style Sheets from Internet Explorer 3 and 4. 27 Concealing Individual Rules . 28 Adjusting for Table Properties . 29 Font Problems to Avoid. 29 Making Margins and Padding Useful. 30 02_579851 ftoc.qxd 5/4/05 11:05 PM Page xii xii Contents Chapter 3: Hiding CSS from Newer Browsers. 33 Controlling Internet Explorer 5 and Above . 34 Managing CSS in Internet Explorer 5.x for Mac. 34 Balancing Internet Explorer 5,5.5, and 6. 37 Taming Gecko-Based Browsers . 48 CSS Hack Strategies . 49 Float Clearing with the :after Pseudo-Element . 49 Filtering Out Safari . 51 The Lang Pseudo-Class Hack . 52 The Exclamation Mark Hack. 52 Handling Opera Problems. 53 Be Nice to Opera Hack . 53 Media Queries Hack . 54 Applying the Owen Hack. 56 Chapter 4: Applying Conditional Comments . 57 About Conditional Comments . 57 Showing/Hiding Styles from Individual Versions . 59 Showing or Hiding a Range of Versions. 60 Working with Non–Internet Explorer Browsers . 62 Practical Applications of Conditional Comments . 63 Three-Pixel Gap . 63 Italics Float Bug. 65 First Letter Bug. 67 Chapter 5: Scripting JavaScript and Document Object Model Hacks . 71 Dynamically Loading Style Sheets . 72 Determining Browsers with JavaScript Objects . 72 Reading the userAgent Property . 73 Styling for a Detected Browser . 75 Switching Style Sheets with the DOM . 76 Style Value Switching for Interactivity . 81 Chapter 6: Coding Server-Side Solutions . 87 Styling with ASP . 87 Controlling CSS with PHP . 91 ColdFusion Integration with CSS. 94 02_579851 ftoc.qxd 5/4/05 11:05 PM Page xiii Contents xiii Chapter 7: Enhancing Graphics and Media with CSS. 99 Styling Images for Controlled Layout . 99 Replacing Styles with Images Automatically. 103 Scaling Images for Accessibility . 105 Making Rounded Rectangles with CSS . 106 Adding Drop-Shadow Styles. 112 Extending PNG Support. 115 Implementing Flash Replacement . 117 Chapter 8: Maintaining Accessibility with CSS . 121 Setting Up for Accessible Text . 122 Handling Print Media Style Sheets . 125 Attaching a Print Media Style Sheet . 125 Defining General Properties. 126 Correcting Print-Specific Problems . 127 Adding CSS Hacks for Screen Readers . 128 Chapter 9: Integrated CSS Hack Layouts. 131 Positioning with CSS. 131 Position: Relative . 132 Position: Absolute . 135 Position: Fixed . 138 Managing the Float . 142 Crafting Two- and Three-Column Designs . 146 Two-Column Layouts . 146 Three-Column Layouts . 151 Placing Footers Correctly. 154 Centering Page Layouts . 156 Chapter 10: Building Navigation Systems . 159 Designing CSS Navigation Bars . 159 Vertical Navigation . 160 Horizontal Navigation . 164 Creating Multilevel Drop-Downs . 166 Crafting CSS Tabs . 170 02_579851 ftoc.qxd 5/4/05 11:05 PM Page xiv xiv Contents Chapter 11: Troubleshooting CSS . 177 Avoiding the Flash of Unstyled Content. 177 Debugging CSS Problems . ..