Web Standards Solutions the Markup and Style Handbook Special Edition
Total Page:16
File Type:pdf, Size:1020Kb
Web Standards Solutions The Markup and Style Handbook Special Edition Dan Cederholm Web Standards Solutions: The Markup and Style Handbook, Special Edition Copyright © 2009 by Dan Cederholm 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-4302-1920-0 ISBN-13 (electronic): 978-1-4302-1921-7 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. 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 kn`ano)ju<olnejcan)o^i*_ki, or visit sss*olnejcankjheja*_ki. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail ejbk<]lnaoo*_ki, or visit sss*]lnaoo*_ki. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at dppl6++sss*]lnaoo*_ki+ejbk+^qhgo]hao. 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 freely available to readers at sss*bneaj`okba`*_ki in the Downloads section. Credits Lead Editor Associate Production Director Ben Renow-Clarke Kari Brooks-Copony Technical Reviewer Production Editor Matt Heerema Laura Cheu Editorial Board Compositor Clay Andres, Steve Anglin, Mark Beckner, Lynn L’Heureux Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Proofreader Michelle Lowman, Matthew Moodie, Duncan Parkes, Lisa Hamilton Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Indexer Matt Wade, Tom Welsh Broccoli Information Management Project Manager Interior and Cover Designer Richard Dal Porto Kurt Krames Copy Editor Manufacturing Director Liz Welch Tom Debolski CONTENTS AT A GLANCE Foreword ..................................................................xvii About the Author ........................................................xviii About the Technical Reviewer .......................................... xix Acknowledgments .........................................................xx Introduction ............................................................... xxi PART ONE GET DOWN WITH MARKUP ........................... 1 Chapter 1 Lists .............................................................. 3 Chapter 2 Headings ........................................................17 Chapter 3 Tables are Evil? ................................................29 Chapter 4 Quotations .....................................................49 Chapter 5 Forms ...........................................................61 Chapter 6 <Strong>, <Em>, and Other Phrase Elements ..............83 Chapter 7 Anchors ........................................................103 Chapter 8 More Lists .....................................................119 Chapter 9 Minimizing Markup ...........................................133 iv PART TWO SIMPLEBITS OF STYLE ...............................147 Chapter 10 Applying CSS .................................................149 Chapter 11 Print Styles ...................................................167 Chapter 12 CSS Layouts ..................................................179 Chapter 13 Styling Text ..................................................207 Chapter 14 Image Replacement .........................................223 Chapter 15 Styling <body> ..............................................243 Chapter 16 Next Steps ...................................................255 Index ...................................................................... 263 v CONTENTS Foreword ..................................................................xvii About the Author ........................................................xviii About the Technical Reviewer .......................................... xix Acknowledgments .........................................................xx Introduction ............................................................... xxi PART ONE GET DOWN WITH MARKUP ........................... 1 Chapter 1 Lists .............................................................. 3 Let’s go shopping ...............................................................4 Quiz time .....................................................................4 Method A: The <br /> breakdown ..............................................4 It’s a wrap ..................................................................5 Method B: The bullet that bites ................................................6 Validation, please ........................................................6 Method C: Getting closer .....................................................6 Method D: Wrapper’s delight ..................................................8 Summary ......................................................................8 Extra credit ....................................................................9 Bite the bullet ..............................................................9 Getting fancier with custom bullets ............................................10 Lists that navigate ..........................................................11 Mini-tab shapes ............................................................14 Chapter 2 Headings ........................................................17 What is the best way to mark up the title of a document? .............................18 Method A: Meaningful? ......................................................18 Method B: The p and b combo ................................................19 Difficult to style .........................................................19 vii CONTENTS Method C: Style and substance ................................................19 Easily styled ............................................................19 Default distaste .........................................................20 Search engine friendly. 20 An aside on heading order ................................................21 Summary .....................................................................21 Extra credit ...................................................................22 Simple styling .................................................................22 Adding backgrounds ........................................................23 Backgrounds and borders .................................................24 Tiled backgrounds .......................................................24 Swappable icons ...........................................................25 Easy updates ...............................................................25 The chameleon effect .......................................................26 Aligning the <img> element ...............................................26 Wrapping up ..................................................................27 Chapter 3 Tables are Evil? ................................................29 Totally tabular .................................................................30 A table that everyone can sit at ..................................................30 Adding a summary .............................................................33 The head(s) of the table ........................................................33 Header and data relationships ....................................................35 Using the abbr attribute ........................................................36 <thead>, <tfoot>, and <tbody> ..................................................37 Are tables evil? ................................................................39 Extra credit ...................................................................39 Creating a grid .............................................................39 Collapsing the gaps .........................................................40 An IE/Mac note .........................................................41 Spaced out .............................................................41 Customizing the headers .....................................................42 Headers with background images ..............................................43 Tiny tile ...............................................................43 The CSS ...............................................................43 Assigning icons to IDs .......................................................44 The icons ..............................................................45 The CSS ...............................................................45 Combining