
732X00FMFINAL.qxd 11/1/06 3:08 PM Page i Pro CSS Techniques Jeff Croft, Ian Lloyd, and Dan Rubin 732X00FMFINAL.qxd 11/1/06 3:08 PM Page ii Pro CSS Techniques Copyright © 2006 by Jeff Croft, Ian Lloyd, and Dan Rubin All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-732-3 ISBN-10 (pbk): 1-59059-732-X Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Chris Mills Technical Reviewer: Wilson Miner Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser, Keir Thomas, Matt Wade Project Manager: Beth Christmas Copy Edit Manager: Nicole Flores Copy Editor: Liz Welch Assistant Production Director: Kari Brooks-Copony Production Editor: Katie Stence Compositor and Artist: Kinetic Publishing Services, LLC Proofreader: Lori Bring Indexer: Broccoli Information Management Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code/ Download section. 732X00FMFINAL.qxd 11/1/06 3:08 PM Page iii For Haley, because everything I do is dedicated to you. —Jeff Croft For Manda. Thanks for the continued support—lloydi loves ya! —Ian Lloyd For Mum, Dad, and Alex—friends, till the end. —Dan Rubin 732X00FMFINAL.qxd 11/1/06 3:08 PM Page iv 732X00FMFINAL.qxd 11/1/06 3:08 PM Page v Contents at a Glance About the Authors . xvii About the Tech Reviewer . xix Acknowledgments . xxi Introduction . xxv ■CHAPTER 1 The Promise of CSS. 1 ■CHAPTER 2 The Language of Style Sheets. 11 ■CHAPTER 3 Specificity and the Cascade. 27 ■CHAPTER 4 The Browsers . 59 ■CHAPTER 5 Managing CSS Files . 73 ■CHAPTER 6 Hacks and Workarounds . 85 ■CHAPTER 7 CSS Layouts. 111 ■CHAPTER 8 Creating Common Page Elements . 163 ■CHAPTER 9 Typography. 191 ■CHAPTER 10 Styling Tables . 219 ■CHAPTER 11 Styling Forms . 235 ■CHAPTER 12 Styling Lists . 255 ■CHAPTER 13 Styling for Print and Other Media. 277 ■CHAPTER 14 Everything Falls Apart . 293 ■APPENDIX A CSS Reference . 323 ■APPENDIX B CSS Specificity Chart . 351 ■APPENDIX C Browser Grading Chart. 355 ■INDEX . 361 v 732X00FMFINAL.qxd 11/1/06 3:08 PM Page vi 732X00FMFINAL.qxd 11/1/06 3:08 PM Page vii Contents About the Authors . xvii About the Tech Reviewer . xix Acknowledgments . xxi Introduction . xxv ■CHAPTER 1 The Promise of CSS . 1 The Advantages of Using CSS for Style . 1 Semantic (X)HTML: Markup with Meaning . 2 What Is Semantic Markup? . 2 How Does Writing Semantic Markup Help You in the Real World?. 3 Creating Semantically Rich (X)HTML Markup . 4 Avoiding Nonstructural Tags . 5 Avoiding “Divitis” and “Classitis” . 5 Choosing Your Markup Language and DOCTYPE . 7 HTML vs. XHTML: Why the Decision Does—and Doesn’t—Matter . 7 DOCTYPE: The Most Underappreciated Tag of All. 8 The Three Layers of a Modern Web Document . 9 Summary . 10 ■CHAPTER 2 The Language of Style Sheets. 11 Adding Style to Your (X)HTML Document. 11 The <link> Tag. 11 Using Multiple Style Sheets . 12 The style Element . 13 Creating a Style Sheet . 14 Declarations . 14 Selectors . 14 Element Selectors . 15 Class Selectors. 15 ID Selectors. 17 vii 732X00FMFINAL.qxd 11/1/06 3:08 PM Page viii viii ■CONTENTS (X)HTML’s Family Tree. 17 Descendant Selectors . 18 Child Selectors . 19 Adjacent Sibling Selectors . 20 Attribute Selectors. 20 Presence of an Attribute . 21 Exact Attribute Value . 21 Partial Attribute Values . 22 Particular Attribute Selector . 22 Pseudo-Classes and Pseudo-Elements . 22 Pseudo-Classes . 23 Pseudo-Elements. 24 Daisy-Chaining Selectors. 24 Grouping Selectors . 25 Summary . 25 ■CHAPTER 3 Specificity and the Cascade. 27 Selectors . 27 Selectors: Simple and Combined . 27 Universal “Star” Selector . ..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages405 Page
-
File Size-