216 Part II: HTML, XHTML, CSS, and Accessibility

216 Part II: HTML, XHTML, CSS, and Accessibility Listing 9-3: (continued)

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In vestibulum vestibulum elit. Ut porta. Duis vulputate bibendum tellus. Vivamus dictum egestas mi. Cras justo. Vestibulum nisl mauris, convallis a, vestibulum et, accumsan vel, lacus. Morbi mattis viverra turpis. Pellentesque blandit quam in sapien. Proin pellentesque, purus sit amet mollis sollicitudin, lacus leo rhoncus enim, nec vestibulum urna tellus at magna. Ut adipiscing.

Morbi ut sem non diam fringilla tincidunt. Maecenas nunc tellus, adipiscing eget, tincidunt ut, venenatis ut, enim. Sed posuere turpis at nisl. Sed at sem. Nullam sagittis tincidunt magna. Duis tempus. Proin dui turpis, consequat quis, porttitor ut, molestie vel, libero. Phasellus sodales venenatis urna.

Maecenas ipsum risus, fringilla rutrum, porta id, congue id, leo. Fusce augue nulla, vestibulum at, euismod ut, ultrices in, felis. Cras vitae pede ac mi lobortis fermentum. Phasellus viverra. Ut ultrices, neque ac congue varius, justo quam elementum mi, at nonummy urna elit quis augue. Praesent feugiat pede a turpis. Duis libero diam, volutpat id, dictum vitae, aliquet sed, lorem.

You can see the results in Figure 9-3. Figure 9-4 shows a styled version of this design scheme in use. Reversing the layout is simple, too. All you need to do is modify the float from right to left and change the borders, as follows:

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

Chapter 9: Laying Out Pages with

Chapter 9: Laying Out Pages with CSS 215 Figure 9-2: A CSS layout using float. complex layout designs. This simple example will help give you a taste of how it works. Listing 9-3: Nested Float < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

214 Part II: HTML, XHTML, CSS, and Accessibility

214 Part II: HTML, XHTML, CSS, and Accessibility Listing 9-2: (continued)

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In vestibulum vestibulum elit. Ut porta. Duis vulputate bibendum tellus. Vivamus dictum egestas mi. Cras justo. Vestibulum nisl mauris, convallis a, vestibulum et, accumsan vel, lacus. Morbi mattis viverra turpis. Pellentesque blandit quam in sapien. Proin pellentesque, purus sit amet mollis sollicitudin, lacus leo rhoncus enim, nec vestibulum urna tellus at magna. Ut adipiscing.

Morbi ut sem non diam fringilla tincidunt. Maecenas nunc tellus, adipiscing eget, tincidunt ut, venenatis ut, enim. Sed posuere turpis at nisl. Sed at sem. Nullam sagittis tincidunt magna. Duis tempus. Proin dui turpis, consequat quis, porttitor ut, molestie vel, libero. Phasellus sodales venenatis urna.

Maecenas ipsum risus, fringilla rutrum, porta id, congue id, leo. Fusce augue nulla, vestibulum at, euismod ut, ultrices in, felis. Cras vitae pede ac mi lobortis fermentum. Phasellus viverra. Ut ultrices, neque ac congue varius, justo quam elementum mi, at nonummy urna elit quis augue. Praesent feugiat pede a turpis. Duis libero diam, volutpat id, dictum vitae, aliquet sed, lorem.

Figure 9-2 shows the results. Secret #150: Nested Float The nested float layout in Listing 9-3 shows how you can nest div elements to get more interesting layouts. Nesting div elements can be an important part of

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Chapter 9: Laying Out Pages with

Chapter 9: Laying Out Pages with CSS 213 Figure 9-1: A CSS layout using positioning. Listing 9-2 shows how. Listing 9-2: Float-based layout, floating left content < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

(continued)

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services

212 Part II: HTML, XHTML, CSS, and Accessibility

212 Part II: HTML, XHTML, CSS, and Accessibility Listing 9-1: (continued)

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In vestibulum vestibulum elit. Ut porta. Duis vulputate bibendum tellus. Vivamus dictum egestas mi. Cras justo. Vestibulum nisl mauris, convallis a, vestibulum et, accumsan vel, lacus. Morbi mattis viverra turpis. Pellentesque blandit quam in sapien. Proin pellentesque, purus sit amet mollis sollicitudin, lacus leo rhoncus enim, nec vestibulum urna tellus at magna. Ut adipiscing.

Morbi ut sem non diam fringilla tincidunt. Maecenas nunc tellus, adipiscing eget, tincidunt ut, venenatis ut, enim. Sed posuere turpis at nisl. Sed at sem. Nullam sagittis tincidunt magna. Duis tempus. Proin dui turpis, consequat quis, porttitor ut, molestie vel, libero. Phasellus sodales venenatis urna.

Maecenas ipsum risus, fringilla rutrum, porta id, congue id, leo. Fusce augue nulla, vestibulum at, euismod ut, ultrices in, felis. Cras vitae pede ac mi lobortis fermentum. Phasellus viverra. Ut ultrices, neque ac congue varius, justo quam elementum mi, at nonummy urna elit quis augue. Praesent feugiat pede a turpis. Duis libero diam, volutpat id, dictum vitae, aliquet sed, lorem.

Figure 9-1 shows the results. Secret #149: Float-Based Layout While not primarily intended for laying out documents, the use of the float property in CSS does allow you to create a number of convenient layouts with minimum fuss. Floating layouts are common because they are functional, flexible, and easy to work with. Floating layouts use the float property and a value of left or right to determine which element gets floated.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Unix Web Hosting services

Chapter 9: Laying Out Pages with

Chapter 9: Laying Out Pages with CSS 211 Floats. Floats in CSS are a means of floating something to the right or left. Intended mostly to float images, floating has become one form of laying out documents. Filters. Filters in this context are a means of bypassing specific browsers while targeting others. Filters are really hacks, but the terminology is used to define specific hacks that are filtering specific browsers. note See Appendix C for helpful resources to assist you in your CSS education. Secret #148: Two-Column Layout, Positioned Left Navigation Using absolute positioning, you can create a two-column layout with a left column menu and right content area. Listing 9-1 shows the CSS and markup used to create the layout. Listing 9-1: Working with positioning in layout < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

(continued)

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

210 Part II: HTML, XHTML, CSS, and Accessibility

210 Part II: HTML, XHTML, CSS, and Accessibility An intriguing development over the past several years has been the move away from table-based design to transitional designs using lighter tables and CSS, or out-and-out pure CSS layouts. CSS ultimately frees the designer by providing much richer and more diverse means of presenting and delivering designs to various media including, but not limited to, the following: Screen Print Projection Audio Braille Television But page layout with CSS is in relatively early days yet, so designers need a lot of additional information to work with their layouts effectively. In this chapter, you ll learn about some of the most practical means of laying out pages. The examples are made simple so you can both begin using them quickly and gain insight into the concepts being employed. Also included in this chapter are numerous hacks to assist you in making sure your CSS layouts are as backward compatible as possible. CSS Layout Basics Several terms and concepts are referred to throughout this chapter, so it s good to let you know them up front: Box Model. Any HTML or XHTML element creates a box, and you can use CSS to access and style aspects of that box, including margins, padding, and borders. There are problems in Box Model implementations which is one of the reasons that CSS layouts require so much attention to detail and often require hacks to ensure proper cross-browser display. Graceful degradation. This is the concept that when styles are removed from a design, the actual text content is still available and easily accessed, even if all the visual layout and design elements are gone. Hack. A hack is any use of code outside its original, intended purpose. Workaround. A workaround is typically an exploitation of a bug within a browser allowing you to bypass support problems. Hacks and workarounds are very similar, and there s always dissent as to whether a hack is a hack, a workaround, or a technique. Positioning. In CSS, you can position element boxes either absolutely, via specific coordinates, or relatively, in relation to other elements. You can create complete layouts with absolute positioning, as is sometimes called for. note The layouts in this chapter use positioning in conjunction with other methods for maximum flexibility. Many visual editors, such as Dreamweaver, use the term layers to refer to absolutely positioned CSS boxes.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

Laying Out Ch9apter Pages with CSS Secrets

Laying Out Ch9apter Pages with CSS Secrets in This Chapter #148: Two-Column Layout, Positioned Left Navigation . . . . . . . . . . . . . . 211 #149: Float-Based Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 #150: Nested Float . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 #151: Three-Column Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 #152: Vertical Centering in CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 #153: Ordering DIVs for Backward Compatibility . . . . . . . . . . . . . . . . . 226 #154: @import for Graceful Degradation . . . . . . . . . . . . . . . . . . . . . . 227 #155: CSS Hacking Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 #156: The Box Model Hack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 #157: The High Pass Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 #158: The Mid Pass Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 #159: IE 5.0 Windows Band Pass Filter . . . . . . . . . . . . . . . . . . . . . . . . 232 #160: IE 5.5 Windows Band Pass Filter . . . . . . . . . . . . . . . . . . . . . . . . 233 #161: Opera Hacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 #162: Understanding CSS Media Types . . . . . . . . . . . . . . . . . . . . . . . 234 #163: Alternate Style Sheet for Print . . . . . . . . . . . . . . . . . . . . . . . . . 235 #164: Alternate Style Sheet for Small-screen Media . . . . . . . . . . . . . . . . 236 #165: Alternate Style Sheet for Projection . . . . . . . . . . . . . . . . . . . . . . 237 #166: CSS Best Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Unix Web Hosting services

Chapter 8: Style Tips for Type

Chapter 8: Style Tips for Type and Design 207 Secret #147: Cool Rules I stumbled upon this technique while writing this chapter. Ethan Marcotte (this book s technical editor) and designer Dunstan Orchard worked together to find a means to style horizontal rules using background graphics. Through a bit of trial and error, Ethan and Dunstan came up with a means to create cross-browser horizontal rule effects including subtle fades. Figure 8-27 shows the results. note To read more about styling horizontal rules, see www.sidesh0w.com/ weblog/2004/03/17/sexily-styling-horizontal-rules.html. Summary Obviously, there are still concerns about the role CSS plays for certain audiences, but CSS has truly emerged as more than just a band-aid solution for font and color control. You can now enhance your pages in so many ways, and I really believe we have only just begun to understand where CSS will take us in terms of visual design. If you reexcited about CSS after this chapter and I hope you are you llbe happy to know you get to spend another chapter with CSS, examining how CSS works for layout, how to manage workarounds, deal with hacks, and write CSS for other media types.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services