www.it-ebooks.info www.it-ebooks.info CSS Pocket Reference www.it-ebooks.info www.it-ebooks.info FOURTH EDITION CSS Pocket Reference Eric A. Meyer Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo www.it-ebooks.info CSS Pocket Reference, Fourth Edition by Eric A. Meyer Copyright © 2011 O’Reilly Media, Inc. All rights reserved. Printed in Canada. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promo- tional use. Online editions are also available for most titles (http://my.safari booksonline.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Editor: Simon St. Laurent Production Editor: Teresa Elsey Proofreader: Teresa Elsey Indexer: Potomac Indexing, LLC Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano Printing History: May 2001: First Edition. July 2004: Second Edition. October 2007: Third Edition. July 2011: Fourth Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. CSS Pocket Reference, the im- ages of salmon, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-1-449-39903-0 [TM] 1310134087 www.it-ebooks.info Contents Preface vii Chapter 1: Basic Concepts 1 Adding Styles to HTML and XHTML 1 Rule Structure 5 Comments 6 Style Precedence 6 Element Classification 9 Element Display Roles 10 Basic Visual Layout 12 Floating 16 Positioning 17 Table Layout 23 Chapter 2: Values 31 Keywords 31 Color Values 32 Number Values 34 Percentage Values 34 Length Values 34 URIs 37 Angles 37 v www.it-ebooks.info Times 38 Frequencies 38 Strings 38 Chapter 3: Selectors 39 Selectors 39 Structural Pseudo-Classes 45 The Negation Pseudo-Class 52 Interaction Pseudo-Classes 53 Pseudo-Elements 57 Media Queries 59 Chapter 4: Property Reference 65 Universal Values 65 Visual Media 66 Paged Media 203 Aural Media 214 Index 231 vi | Table of Contents www.it-ebooks.info Preface Cascading Style Sheets (CSS) is the W3C standard for the visual presentation of web pages (although it can be used in other settings as well). After a short introduction to the key concepts of CSS, this pocket reference provides an alphabetical reference to all CSS3 selectors, followed by an alphabetical reference to CSS3 properties. Conventions Used in This Book The following typographical conventions are used in this book: Italic Used to indicate new terms, URLs, filenames, file exten- sions, directories, commands and options, and program names. For example, a path in the filesystem will appear as C:\windows\system. Constant width Used to show the contents of files or the output from commands. Constant width italic Shows text that should be replaced with user-supplied values or by values determined by context. vii www.it-ebooks.info Using Code Examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and docu- mentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For ex- ample, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require per- mission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For ex- ample: “CSS Pocket Reference by Eric A. Meyer (O’Reilly). Copyright 2011 O’Reilly Media, Inc., 978-1-449-39903-0.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected]. Safari® Books Online Safari Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative reference books and videos to find the answers you need quickly. With a subscription, you can read any page and watch any video from our library online. Read books on your cell phone and mobile devices. Access new titles before they are available for print, and get exclusive access to manuscripts in develop- ment and post feedback for the authors. Copy and paste code samples, organize your favorites, download chapters, book- mark key sections, create notes, print out pages, and benefit from tons of other time-saving features. viii | Preface www.it-ebooks.info