Transcript
  • HTML & CSS: The Complete Reference,

    Fifth Edition

  • About the AuthorThomas A. Powell ([email protected]) is a long-time industry veteran. After an early stint at CERFnet in the early 90s, he founded Powell Internet Consulting (later renamed PINT) in 1994, a Web design and consulting services firm. Today, PINT (pint.com) provides Web development, design, and consulting services to large and small corporations all over the United States in a variety of industries.

    Beyond his involvement at PINT, Thomas is heavily involved in the academic community. He developed the University of California, San Diego Extension Web Publishing program in the late 1990s and continues to teach classes there in Web development and design. He is also an instructor for the UCSD Computer Science Department, where he teaches classes in Web development and the theory of programming languages.

    Mr. Powell is well published, and his work has appeared in numerous trade publications. He continues to publish regularly in Network World. He also has published numerous books on Web technology and design, including Ajax: The Complete Reference, JavaScript: The Complete Reference, and many others. His books have been translated into over 12 languages and are used around the world both in industry and college settings.

    About the Technical EditorJames H. (Jim) Pence is a full-time writer, editor, speaker, singer, and performance chalk artist. Jim broke into book publishing in 2001 with How to Do Everything with HTML, a how-to book on Web authoring, written by a nontechie for nontechies, and published by McGraw-Hill Professional. He followed this book the same year with another book for McGraw-Hill: Cascading Style Sheets: A Beginners Guide. McGraw-Hill published a second edition of Jims HTML book, re-titled How to Do Everything with HTML & XHTML, in 2003.

    Jim is also a published novelist. He is the author of Blind Sight (Tyndale, 2003), a suspense/thriller novel set in the mind-control cults, and The Angel (Kregel, 2006), set against the backdrop of the euthanasia and physician-assisted suicide movements. Jim moved into true crime writing with his latest book, Terror by Night (Tyndale, 2009). Terror by Night is the true story of the brutal 2008 murders of the Caffey family in Emory, Texas. You can learn more about Jims books and other creative projects at his Web site: www.jamespence.com.

  • HTML & CSS: The Complete Reference,

    Fifth EditionThomas A. Powell

    New York Chicago San Francisco Lisbon London Madrid Mexico City

    Milan New Delhi San Juan Seoul Singapore Sydney Toronto

  • Copyright 2010 by The McGraw-Hill Companies. All rights reserved. Except as permitted under the United States Copyright Act of 1976, nopart of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without theprior written permission of the publisher.

    ISBN: 978-0-07-174170-5

    MHID: 0-07-174170-4

    The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-149629-2, MHID: 0-07-149629-7.

    All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name,we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Wheresuch designations appear in this book, they have been printed with initial caps.

    McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. To contact a representative please e-mail us at [email protected].

    Information has been obtained by McGraw-Hill from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, McGraw-Hill, or others, McGraw-Hill does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information.

    TERMS OF USE

    This is a copyrighted work and The McGraw-Hill Companies, Inc. (McGraw-Hill) and its licensors reserve all rights in and to the work.Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy ofthe work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute,disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hills prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail tocomply with these terms.

    THE WORK IS PROVIDED AS IS. McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THEACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANYINFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that thefunctions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill norits licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstancesshall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result fromthe use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shallapply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.

  • Contents at a Glance

    Part I Core Markup

    1 Traditional HTML and XHTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 Introducing HTML5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3 HTML and XHTML Element Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

    Part II Core Style

    4 Introduction to CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 5 CSS Syntax and Property Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 6 CSS3 Proprietary and Emerging Features Reference . . . . . . . . . . . . . . . . . . 613

    Part III Appendixes

    A Character Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727 B Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751 C Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765 D URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783 E Reading a Document Type Denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 801

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809

    v

  • This page intentionally left blank

  • ContentsAcknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

    Part I Core Markup

    1 Traditional HTML and XHTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3First Look at HTML and XHTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Hello HTML and XHTML World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    Viewing Markup Locally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Viewing Markup with a Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    HTML and XHTML: Version History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14HTML and XHTML DTDs: The Specications Up Close . . . . . . . . . . . . . . . . 16

    Document Type Statements and Language Versions . . . . . . . . . . . . . 18(X)HTML Document Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    The Document Head . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23The Document Body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    Browsers and (X)HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37The Doctype Switch and Browser Rendering Modes . . . . . . . . . . . . . 39

    The Rules of (X)HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41HTML Is Not Case Sensitive, XHTML Is . . . . . . . . . . . . . . . . . . . . . . . 41Attribute Values May Be Case Sensitive . . . . . . . . . . . . . . . . . . . . . . . . 42(X)HTML Is Sensitive to a Single Whitespace Character . . . . . . . . . . 42(X)HTML Follows a Content Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Elements Should Have Close Tags Unless Empty . . . . . . . . . . . . . . . . 43Unused Elements May Minimize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Elements Should Nest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Attributes Should Be Quoted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Entities Should Be Used for Special Characters . . . . . . . . . . . . . . . . . . 44Browsers Ignore Unknown Attributes and Elements . . . . . . . . . . . . . 44

    Major Themes of (X)HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Logical and Physical Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Standards vs. Practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46Myths and Misconceptions About HTML and XHTML . . . . . . . . . . . 47

    The Future of MarkupTwo Paths? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49XHTML: Web Page Markup XML Style . . . . . . . . . . . . . . . . . . . . . . . . 49HTML5: Back to the Future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    2 Introducing HTML5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Hello HTML5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Loose Syntax Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58XHTML5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

    vii

  • viii HTML & CSS: The Complete Reference viii HTML & CSS: The Complete Reference

    HTML5: Embracing the Reality of Web Markup . . . . . . . . . . . . . . . . . . . . . . . 62Presentational Markup Removed and Redened . . . . . . . . . . . . . . . . . . . . . . 63

    Out with the Old Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64In with the New Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Sample of New Attributes for HTML5 . . . . . . . . . . . . . . . . . . . . . . . . . 66

    HTML5 Document Structure Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Adding Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    Marking Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Indicating Dates and Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Inserting Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Specifying Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

    HTML5s Open Media Effort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Media Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

    Client-Side Graphics with . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82Drawing and Styling Lines and Shapes . . . . . . . . . . . . . . . . . . . . . . . . 85Drawing Arcs and Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90Scaling, Rotating, and Translating Drawings . . . . . . . . . . . . . . . . . . . . 93Using Bitmaps in Drawings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97Text Support for canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

    HTML5 Form Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101New Form Field Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101Validating Data Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104Autocomplete Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Miscellaneous Usability Improvements . . . . . . . . . . . . . . . . . . . . . . . . 105

    Emerging Elements and Attributes to Support Web Applications . . . . . . . . 106menu Element Repurposed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106command Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108meter and progress Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109details Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109output Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110The Uncertain Future of Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110The draggable Attribute and the Drag and Drop API . . . . . . . . . . . . 112contenteditable Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114spellcheck Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

    Internationalization Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116HTML5 Metadata Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

    data-X Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116Microdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

    HTML5: Beyond Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120defer Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121HTML, JavaScript, and the DOM Renewed . . . . . . . . . . . . . . . . . . . . . 121Standardizing and Extending Ad Hoc JavaScript Conventions . . . . 125

    Major HTML5 Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126HTML5 Today or Tomorrow? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126HTML5 as a Catch-All . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130HTML5: Web Politics as Usual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131HTML5: Imperfect Improvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

  • 3 HTML and XHTML Element Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Flavors of HTML and XHTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Core Attributes Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

    class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136id . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

    Language Attributes Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138lang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

    Other Common Attributes Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139accesskey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140contenteditable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140datad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141dataformatas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141datasrc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141disabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141hidefocus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141hspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141tabindex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142unselectable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142vspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

    Common HTML5 Attributes Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142accesskey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142contenteditable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143contextmenu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143data-X (Custom Data Attributes) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143draggable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144hidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144itemid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144itemprop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144itemref . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145itemscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145itemtype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146spellcheck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146tabindex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

    Event Attributes Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146HTML5 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146Internet Explorers Extended Event Attributes . . . . . . . . . . . . . . . . . . 147

    HTML Element Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 (Comment) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 (Conditional Comment) . . . . . . . . . . . . . . . . . . . . . . . . . . 155 (Document Type Denition) . . . . . . . . . . . . . . . . . . . 157 (Anchor) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 (Abbreviation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 (Acronym) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

    C o n t e n t s ix

  • x HTML & CSS: The Complete Reference x HTML & CSS: The Complete Reference

    (Address) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 (Java Applet) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 (Image Map Area) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 (Article) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 (Aside) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 (Audio) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 (Bold) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 (Base URL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 (Base Font) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 (Bidirectional Override) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 (Background Sound) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 (Big Font) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 (Blinking Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 (Block Quote) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 (Document Body) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 (Line Break) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 (Form Button) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 (Canvas for Drawing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 (Table Caption) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 (Center Alignment) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 (Citation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 (Code Listing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 (Table Column) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 (Table Column Group) . . . . . . . . . . . . . . . . . . . . . . . . . . 216 (Command) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 (Comment Information) . . . . . . . . . . . . . . . . . . . . . . . . . 220 (List of Prell Data) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 (Denition Description in a Denition List

    or Content in Details or Figure) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 (Deleted Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 (Additional Details) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 (Denition) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 (Directory List) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 (Division) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 (Denition List) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 (Term in a Denition List or

    Caption in Figure or Details) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 (Emphasis) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 (Embedded Object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 (Form Field Grouping) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 (Figure) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 (Font Denition) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 (Footer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 (Form for User Input) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 (Window Region) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 (Frameset Denition) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 through (Headings) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 (Document Head) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 (Header) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 (Header Group) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

  • (Horizontal Rule) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 (HTML Document) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 (Italic) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 (Inline Frame) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 (Inow Layer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 (Image) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 (Input Form Control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 (Inserted Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 (Index Prompt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 (Keyboard Input) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 (Key Pair Generation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 (Form Control Label) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 (Positioned Layer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 (Descriptive Legend) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 (List Item) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 (Link to External Files or Set Relationships) . . . . . . . . . . . . . 303 (Code Listing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 (Client-Side Image Map) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 (Marked Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 (Marquee Display) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 (Menu List or Command Menu) . . . . . . . . . . . . . . . . . . . . . 318 (Meta-Information) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 (Scalar Gauge) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 (Multiple Column Text) . . . . . . . . . . . . . . . . . . . . . . . . . . 325 (Navigation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 (No Line Breaks) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 (No Embedded Media Support) . . . . . . . . . . . . . . . . . . 328 (No Frame Support Content) . . . . . . . . . . . . . . . . . . . . 329 (No Script Support Content) . . . . . . . . . . . . . . . . . . . . . . 330 (Embedded Object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 (Ordered List) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 (Option Grouping) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 (Option in Selection List) . . . . . . . . . . . . . . . . . . . . . . . . . . 339 (Form Output) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 (Paragraph) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 (Object Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 (Plain Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 (Preformatted Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 (Progress Indicator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 (Quote) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 (Ruby Parentheses) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 (Ruby Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 (Ruby Annotation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 (Strikethrough) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 (Sample Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 (Scripting) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 (Section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 (Selection List) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 (Small Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 (Source) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

    C o n t e n t s xi

  • xii HTML & CSS: The Complete Reference xii HTML & CSS: The Complete Reference

    (Extra Space) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 (Text Span) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 (Strikeout Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376 (Strong Emphasis) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 (Style Information) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 (Subscript) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 (Superscript) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 (Table) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 (Table Body) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 (Table Data) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 (Multiline Text Input) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 (Table Footer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 (Table Header) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 (Table Header) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 (Time) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408 (Document Title) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 (Table Row) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 (Teletype Text) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 (Underline) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 (Unordered List) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 (Video) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 (Word Break) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 (XML Data Island) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424 (Example) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425

    Part II Core Style

    4 Introduction to CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429Presentational HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429The Slow Rise of CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430First Look at CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432Hello CSS World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438CSS Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440

    Proprietary CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440CSS Relationship with Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

    The Specication of CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443CSS Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445Validating CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447Breaking the Rules Purposefully? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450

    Applying Style to a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452Linking to a Style Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452Embedding Style Sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456Importing Style Sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458Inline Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459

    Media Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461Printer-Specic CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

    Alternative Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464User Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466

  • Document Structure and CSS Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468!important Override . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470

    Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470Element Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471id Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471class Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473Contextual Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476Attribute Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479Pseudo-Element Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484Pseudo-Class Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

    CSS Properties Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500Measurements and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502CSS and (X)HTML Elements Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . 506

    Physical Markup and Overriding Expected Results . . . . . . . . . . . . . . 506Are and the Most Popular Tags? . . . . . . . . . . . . . . . . . 507Changing Element Types with display . . . . . . . . . . . . . . . . . . . . . . . . . 508Controlling White Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512

    Major Themes of CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513Separation of Structure and Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514CSS: More Appropriate and Powerful for Presentation . . . . . . . . . . . 516Cross-Browser CSS Madness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517Myths and Misconceptions Related to CSS . . . . . . . . . . . . . . . . . . . . . 517

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519

    5 CSS Syntax and Property Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521CSS Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521CSS Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521Style Inclusion Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524

    Linked Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524Embedded Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526Imported Styles@import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526Inline Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527

    CSS Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527CSS Strings and Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529

    Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530CSS Color Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530CSS Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533Miscellaneous CSS Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539

    /* comments */ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539@charset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540@font-face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540@media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541@page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541!important . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542

    CSS1 and CSS 2.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543background-attachment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543background-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544background-image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544background-position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545

    C o n t e n t s xiii

  • xiv HTML & CSS: The Complete Reference xiv HTML & CSS: The Complete Reference

    background-repeat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546border . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547border-bottom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547border-bottom-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548border-bottom-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548border-bottom-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548border-collapse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549border-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549border-left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550border-left-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551border-left-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551border-left-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552border-right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552border-right-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552border-right-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553border-right-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553border-spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553border-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554border-top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556border-top-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556border-top-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557border-top-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557border-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557bottom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559caption-side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560clip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562counter-increment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564counter-reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568empty-cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570oat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572font-family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572font-size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573font-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574font-variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575font-weight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577letter-spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578line-height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578list-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579list-style-image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579list-style-position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579list-style-type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580

  • margin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581margin-bottom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582margin-left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582margin-right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583margin-top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583max-height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584max-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584min-height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585min-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585orphans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586outline-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588outline-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589outline-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590overow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591padding-bottom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593padding-left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593padding-right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594padding-top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594page-break-after . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595page-break-before . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595page-break-inside . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596quotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598table-layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598text-align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599text-decoration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599text-indent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600text-transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601unicode-bidi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602vertical-align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603white-space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604widows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605word-spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606z-index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607

    CSS2 and CSS 2.1 Aural Style Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607

    6 CSS3 Proprietary and Emerging Features Reference . . . . . . . . . . . . . . . . . . 613The State of CSS3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613

    CSS3 Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613CSS3-Introduced Values and Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621CSS3 Color Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624Media Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625Web Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626Miscellaneous CSS3 Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629

    C o n t e n t s xv

  • xvi HTML & CSS: The Complete Reference xvi HTML & CSS: The Complete Reference

    Implemented CSS3 and Browser-Specic Features . . . . . . . . . . . . . . . . . . . . . 629@keyframes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630accelerator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632animation-delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633animation-direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634animation-duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635animation-iteration-count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636animation-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637animation-timing-function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638backface-visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640background-clip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641background-origin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642background-position-x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643background-position-y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644background-size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649border-bottom-left-radius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650border-bottom-right-radius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651border-image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651border-radius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653border-top-left-radius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654border-top-right-radius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655box-reect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655box-shadow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656box-sizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658column-break-after . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659column-break-before . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659column-count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660column-gap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661column-rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661column-rule-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662column-rule-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663column-rule-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664column-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665lter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671image-rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673ime-mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673interpolation-mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674layout-grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674layout-grid-char . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675layout-grid-line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675layout-grid-mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676layout-grid-type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676line-break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677marquee-direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677

  • marquee-play-count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678marquee-speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679marquee-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681mask-attachment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682mask-box-image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682mask-clip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683mask-composite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684mask-image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684mask-origin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685mask-position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685mask-position-x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686mask-position-y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687mask-repeat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687mask-size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688opacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690outline-offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690outline-radius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691overow-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691overow-x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692overow-y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693perspective-origin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694resize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695ruby-align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696ruby-overhang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697ruby-position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698scrollbar-3dlight-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698scrollbar-arrow-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699scrollbar-base-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699scrollbar-darkshadow-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700scrollbar-face-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701scrollbar-highlight-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701scrollbar-shadow-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702scrollbar-track-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703text-align-last . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704text-autospace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704text-ll-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705text-justify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705text-kashida-space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706text-overow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707text-rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708text-shadow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708text-stroke . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710text-stroke-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710text-stroke-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711text-underline-position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712

    C o n t e n t s xvii

  • xviii HTML & CSS: The Complete Reference xviii HTML & CSS: The Complete Reference

    transform-origin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715transform-style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717transition-delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717transition-duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718transition-property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719transition-timing-function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719user-select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720word-break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721word-wrap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722writing-mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724

    Part III Appendixes

    A Character Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727Encoding Quirks and Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . 728

    Traditional HTML Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731HTML 4.x and XHTML 1.x Character Entities . . . . . . . . . . . . . . . . . . . . . . . . . 740

    Latin Extended-A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741Latin Extended-B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741Spacing Modier Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741General Punctuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741Greek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743Letter-like Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744Arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745Mathematical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746Technical Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747Geometric Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748Miscellaneous Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748

    Embracing Unicode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748

    B Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751Specifying Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751

    Fonts for Windows Platform and Browsers . . . . . . . . . . . . . . . . . . . . . 752Fonts for Macintosh System and Browsers . . . . . . . . . . . . . . . . . . . . . . 755PC Mac Font Similarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757

    Downloadable Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 760Microsofts Dynamic Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 760Standard Downloadable Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 761Cross-Browser Downloadable Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . 761

    Font Replacement with Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763sIFR and Other Text Replacement Techniques . . . . . . . . . . . . . . . . . . . . . . . . . 764

    C Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765(X)HTML Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765

    Nonstandard Color Names and Numerical Equivalents . . . . . . . . . . 765(X)HTML Elements Supporting Color . . . . . . . . . . . . . . . . . . . . . . . . . 772

  • CSS Color Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773CSS Color-Related Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776

    Browser-Safe Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779

    D URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783

    Server Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 786Filename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787Fragment Identier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788Other Features of URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789

    Data URIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 791Other Emerging URL Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794Relative URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 795

    Using the Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 795URL Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796

    Unclear Case Sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797Unclear Length Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797Persistence Concerns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797Long, Dirty URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797Short, Cryptic URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797Location, Not Meaning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 798

    Beyond URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 798New Addressing Schemes: URNs, URCs, and URIs . . . . . . . . . . . . . . 798

    E Reading a Document Type Denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 801Element Type Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 801Occurrence Indicators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 802Logical Connectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803SGML Content Exclusion and Inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 804Attribute Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 804SGML and XML Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805Parameter Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806The DTDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809

    C o n t e n t s xix

  • This page intentionally left blank

  • Acknowledgments

    The fifth edition of this book might as well be the first edition of a brand-new book. The HTML5 specification marks a return to past ideas and an explosion of future ideas. It took a great deal of work to put this new edition together. Given the amount of effort required, I want to make sure that all those that helped are given their due. First, I want to acknowledge the numerous fixes and improvements that came from the feedback from both my students at UCSD and readers around the world. I write these books for you, and I am glad you are putting this information to good use.

    I would also like to show my appreciation to the many staff members at PINT who helped on this book project in some direct or indirect way. I cant specifically thank and mention the dozens of employees we have at PINT and my other firm Port80 Software who keep the lights on, but Ill call a few out who warrant some extra kudos.

    Christie Sorenson once again helped this time with heavy lifting particularly in the CSS effort, and I can safely say that she has learned, relearned, and even forgotten more about Web development than probably anyone I know, besides maybe myself. Looking forward to more project fun in the future, Christie!

    Plenty of other PINTsters helped. Rob McFarlane, Andrew Simpkins, and Bryan Sleiter helped out with imagery. The project managers, particularly Mine Okano, Robin Nobel, Matt Plotner, and Olivia Chen, gave me moral support and occasional pity as I toiled away upstairs. Glenn Dawson addressed my many server changes and helped debug some annoying aspects of HTML5. Dan Whitworth assisted on a few chapters here and there and probably had nightmares about getting a call to really dive in.

    Joe Lima listened to some of my verbal nonsense and helped guide me to some deeper insights than I could have ever arrived at on my own.

    Daisy Bhonsle kept up a very long-standing proofing relationship, and I am very glad she always helps out. The student certainly has become the master.

    The folks at McGraw-Hill Professional are always a pleasure to work with. Meghan Riley helped guide me along, and Megg Morin didnt lose faith, at least not completely. Thanks for being my patron the last decade, Megg!

    My technical editor, James Pence, probably wondered when this project was going to finish, and somehow he finished a nontechnical book of his own during the project.

    xxi

  • xxii HTML & CSS: The Complete Reference

    Finally, to my friends and family who tried to give me space to write this thing, you deserve the biggest thanks. My children, Graham, Olivia, and Desmond, had to put up with a grouchy dad and far too many absent weekends, so we now return you to our regularly scheduled weekends! Cecilia, you provided a lot of help as well that made things a bit easier on all of us, so thank you for that. Finally, Sylvia, you always support my online efforts, as hard as they may be. I know you, more than anyone, appreciate the importance of this project, considering the role HTML has played in our lives.

    Thomas A. Powell [email protected] October 2009

  • I n t r o d u c t i o n xxiii

    Introduction

    The fifth edition of this book represents a significant change in structure and content to address HTML5. The book is similar to the previous edition in maybe a third of the content; otherwise, it is an all-new effort. Most obviously, as compared to the previous editions, which focused mainly on XHTML and HTML 4, this edition focuses on HTML5, which represents both a return to the markup past and the unveiling of an exciting future of Web applications. However, we do retain some information from previous editions because in order for this work to be truly complete, we must not focus only on the future but also present all the elements supported in browsers today, including the archaic, proprietary, and standard (X)HTML tags. These will still be encountered for years to come, and we want this book to provide the reference you need in addressing their syntax.

    CSS coverage has been expanded greatly to fully cover CSS 2.1 as well as every proprietary and emerging CSS 3 property supported in one or more popular shipping browsers circa 2009. No value judgment is made; if Internet Explorer has supported a proprietary CSS feature for the last decade, its included. However, we do avoid presenting CSS features that are truly speculative in great depth, but where appropriate, we summarize or present pointers to the emerging syntax.

    The ramification of the increased markup and CSS coverage is simply the book doesnt have space left to do everything it did before. Teaching nearly everything about HTML and CSS in prose form and then presenting a complete syntax reference for the technologies would have produced a book well over 2,000 pages. We were well on the way to that when we adjusted our efforts to create what you have in your hands, a solid reference book that may be used for years to come. This isnt to say that learning material is not present at all. There are very solid introductory chapters for the markup and CSS sections, which should succinctly address details and standards issues. There just isnt a step-by-step cookbook for each element or property. Given the maturity of the Web industry, we aimed not for the complete tutorial, but instead for the complete reference.

    It should go without saying that more markup changes to HTML and CSS are inevitable. HTML5, in particular, is a complete moving target, and rather than punting on it, we took the best shot at its first release version as it settled in late 2009. Because of the inevitable changes given HTML5s rapid evolution, the support Web site, http://htmlref.com, should be considered an important bookmark for readers looking for updates or the unavoidable correction.

    xxiiixxiii

  • This page intentionally left blank

  • ICore Markup CHAPTER 1

    Traditional HTML and XHTML

    CHAPTER 2Introducing HTML5

    CHAPTER 3HTML and XHTML Element Reference

    PART

  • This page intentionally left blank

  • 1Traditional HTML and XHTML

    Markup languages are ubiquitous in everyday computing. Although you may not realize it, word processing documents are filled with markup directives indicating the structure and often presentation of the document. In the case of traditional word processing documents, these structural and presentational markup codes are more often than not behind the scenes. However, in the case of Web documents, markup in the form of traditional Hypertext Markup Language (HTML) and its Extensible Markup Language (XML)-focused variant, XHTML, is a little more obvious. These not-so-behind-the-scenes markup languages are used to inform Web browsers about page structure and, some might argue, presentation as well.

    First Look at HTML and XHTMLIn the case of HTML, markup instructions found within a Web page relay the structure of the document to the browser software. For example, if you want to emphasize a portion of text, you enclose it within the tags and , as shown here:

    This is important text!

    33

    CHAPTER

  • 4 P a r t I : C o r e M a r k u p 4 P a r t I : C o r e M a r k u p

    When a Web browser reads a document that has HTML markup in it, it determines how to render it onscreen by considering the HTML elements embedded within the document:

    So, an HTML document is simply a text file that contains the information you want to publish and the appropriate markup instructions indicating how the browser should structure or present the document.

    Markup elements are made up of a start tag, such as , and typically, though not always, an end tag, which is indicated by a slash within the tag, such as . The tag pair should fully enclose any content to be affected by the element, including text and other HTML markup.

    NOTE There is a distinction between an element (for example, strong) and the tags ( and ) that are used by the element. However, you will likely often find the word tag used in place of element in many if not most discussions about HTML markup. This observation even includes historically relevant documents discussing HTML1 written by Tim Berners-Lee, the founding father of the Web. Fortunately, despite any imprecision of word choice that people may exhibit when discussing markup, meaning is usually well understood and this should not be a tremendous concern.

    Under traditional HTML (not XHTML), the close tag for some elements is optional because their closure can be inferred. For example, a tag cannot enclose another tag, and thus the closing tag can be inferred when markup like this is encountered:

    This is a paragraph. This is also a paragraph.

    Such shortened notations that depend on inference may be technically correct under the specification, but stylistically they are not encouraged. It is always preferable to be precise, so use markup like this instead:

    This is a paragraph. This is also a paragraph.

    1 Historic intro to HTML that clearly uses the term tag instead of element www.w3.org/History/19921103-hypertext/hypertext/WWW/MarkUp/Tags.html

  • C h a p t e r 1 : T r a d i t i o n a l H T M L a n d X H T M L 5 C h a p t e r 1 : T r a d i t i o n a l H T M L a n d X H T M L 5PART I

    There are markup elements, called empty elements, which do not enclose any content, thus need no close tags at all, or in the case of XHTML use a self-close identification scheme. For example, to insert a line break, use a single tag, which represents the empty br element, because it doesnt enclose any content and thus has no corresponding close tag:

    However, in XML markup variants, particularly XHTML, an unclosed tag is not allowed, so you need to close the tag

    or, more commonly, use a self-identification of closure like so:

    The start tag of an element might contain attributes that modify the meaning of the tag. For example, in HTML, the simple inclusion of the noshade attribute in an tag, as shown here:

    indicates that there should be no shading applied to this horizontal rule. Under XHTML, such style attributes are not allowed, because all attributes must have a value, so instead you have to use syntax like this:

    As the preceding example shows, attributes may require values, which are specified with an equal sign; these values should be enclosed within double or single quotes. For example, using standard HTML syntax,

    specifies four attributes for this tag that are used to provide more information about the use of the included image. Under traditional HTML, in the case of simple alphanumeric attribute values, the use of quotes is optional, as shown here:

    Regardless of the flexibility provided under standard HTML, you should always aim to use quotes on all attributes. You will find that doing so makes markup more consistent, makes upgrading to stricter markup versions far easier, and tends to help reduce errors caused by inconsistency.

  • 6 P a r t I : C o r e M a r k u p 6 P a r t I : C o r e M a r k u p

    A graphical overview of the HTML markup syntax shown so far is presented here:

    Hello HTML and XHTML WorldGiven these basics of HTML syntax, it is best now to look at an example document to see its application. Our first complete example written in strict HTML 4 is shown here:

    Hello HTML 4 World Welcome to the World of HTML HTML really isn't so hard! Soon you will using HTML. You can put lots of text here if you want. We could go on and on with fake text for you to read, but let's get back to the book.

    ONLINE http://htmlref.com/ch1/html4helloworld.html

    A simple modification of the initial line is really all that is necessary to make this an HTML5 example, the comment and text is changed so you can keep the examples straight:

    Hello HTML5 World Welcome to the Future World of HTML5 HTML5 really isn't so hard!

    Example Heading

    TagName

    AttributeName

    AttributeAffected ContentStart Tag

    HTML Element

    AttributeValue

    EndTag

  • C h a p t e r 1 : T r a d i t i o n a l H T M L a n d X H T M L 7 C h a p t e r 1 : T r a d i t i o n a l H T M L a n d X H T M L 7PART I

    Soon you will using HTML. You can put lots of text here if you want. We could go on and on with fake text for you to read, but let's get back to the book.

    ONLINE http://htmlref.com/ch1/html5helloworld.html

    In the case of XHTML, which is a form of HTML that is based upon the syntax rules of XML, we really dont see many major changes yet in our example:

    Hello XHTML World Welcome to the World of XHTML XHTML really isn't so hard either! Soon you will using XHTML too. There are some differences between XHTML and HTML but with some precise markup you'll see such differences are easily addressed.

    ONLINE http://htmlref.com/ch1/xhtmlhelloworld.html

    The preceding examples use some of the most common elements used in (X)HTML documents, including:

    The statement, which indicates the particular version of HTML or XHTML being used in the document. The first example uses the strict 4.01 specification, the second uses a reduced form for HTML5 the meaning of which will be explained a bit later on, and the final example uses the XHTML 1.0 strict specification.

    The , , and tag pairs are used to specify the general structure of the document. The required inclusion of the xmlns attribute in the tag is a small difference required by XHTML.

    The tag used in the examples indicates the MIME type of the document and the character set in use. Notice that in the XHTML example, the element has a trailing slash to indicate that it is an empty element.

    The and tag pair specifies the title of the document, which generally appears in the title bar of the Web browser.

    A comment is specified by , allowing page authors to provide notes for future reference.

  • 8 P a r t I : C o r e M a r k u p 8 P a r t I : C o r e M a r k u p

    The and header tag pair indicates a headline specifying some important information.

    The tag, which has a self-identifying end tag () under XHTML, inserts a horizontal rule, or bar, across the screen.

    The and paragraph tag pair indicates a paragraph of text.

    A special character is inserted using a named entity (), which in this case inserts a heart dingbat character into the text.

    The and tag pair surrounds a small piece of text to emphasize which a browser typically renders in italics.

    There are numerous other markup elements that may be employed, all of which will be explored throughout the book, but for now this sampling is enough to get our first example rendered in a browser.

    NOTE Examples in the book will generally be presented in HTML5. Syntax specific to particular browsers, older HTML variants, or XHTML will always be noted when used.

    Viewing Markup LocallyUsing a simple text editor, type in either one of the previous examples and save it with a filename such as helloworld.html or helloworld.htm; you can choose which file extension to use, .htm or .html, but whichever you pick for development, aim to be consistent. This book uses .html for all of the files.

    After you save the example file on your local file system, open it in your Web browser by opening the File menu and choosing Open, Open Page, or Open File, depending on your browser:

  • C h a p t e r 1 : T r a d i t i o n a l H T M L a n d X H T M L 9 C h a p t e r 1 : T r a d i t i o n a l H T M L a n d X H T M L 9PART I

    Once your browser reads the file, it should render a page like the


Top Related