Learn HTML and CSS with w3Schools by W3Schools


9456d056347a120.jpg Author W3Schools
Isbn 9780470611951
File size 19 Mb
Year 2010
Pages 240
Language English
File format PDF
Category web development



 

Learn HTML and CSS with w3schools Hege Refsnes, Ståle Refsnes, Kai Jim Refsnes, Jan Egil Refsnes with C. Michael Woodward Wiley Publishing, Inc. Learn HTML and CSS with w3schools Published by Wiley Publishing, Inc. 111 River Street Hoboken, NJ 07030-5774 www.wiley.com Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-61195-1 LOC/CIP: 2010924594 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Permission Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 7486011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. w3schools and the w3schools logo are registered trademarks of w3schools. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress CIP Data is available from the publisher. w3schools Authors/Editors w3schools’ mission is to publish well-organized and easy-to-understand online tutorials based on the W3C Web standards. Hege Refsnes Hege is a writer and editor for w3schools. She works to improve the usability and accessibility of the Web. Hege has been writing tutorials for w3schools since 1998. Ståle Refsnes Ståle has ten years of Internet development experience, developing all the Webbased solutions for The Norwegian Handball Federation. Ståle has been writing tutorials for w3schools since 1999. Kai Jim Refsnes Kai Jim has been around computers since childhood, working with them since the age of 14. He has been writing tutorials for w3schools since completing a bachelor’s degree in information technology in 2005. Jan Egil Refsnes Jan Egil is the president and founder of w3schools. He is a senior system developer with a master’s degree in information technology and more than 30 years of computing experience. “Jani” has supervised a large number of company-critical development projects for oil companies like Amoco, British Petroleum, ELF, Halliburton, and Brown & Root. He has also developed computer-based solutions for more than 20 governmental institutions like The National Library, Norwegian High Schools, The State Hospital, and many others. Jani started w3schools in 1998. Credits Acquisitions Editor Scott Meyers Production Abshier House Copy Editor Abshier House Associate Director of Marketing David Mayhew Production Manager Tim Tate Proofreading and Indexing Abshier House Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Barry Pruett Associate Publisher Jim Minatel Project Coordinator, Cover Lynsey Stanford Cover Designer Michael Trent Table of Contents Section I: HTML Basic...........................5 Chapter 1: HTML Getting Started..................................................................7 What You Need.....................................................................................................7 HTML Editors......................................................................................................7 Create Your Own Test Web....................................................................................8 .HTM or .HTML Extension?................................................................................8 Chapter 2: HTML Fundamentals....................................................................9 HTML Headings...................................................................................................9 HTML Paragraphs...............................................................................................10 HTML Links.......................................................................................................11 HTML Images.....................................................................................................11 Chapter 3: HTML Elements.........................................................................13 HTML Elements.................................................................................................13 HTML Element Syntax.......................................................................................13 Nested Elements..................................................................................................14 Don't Forget the End Tag....................................................................................15 Empty HTML Elements......................................................................................16 Use Lowercase Tags..............................................................................................16 Chapter 4: HTML Attributes.........................................................................17 Standard HTML Attributes.................................................................................17 Defining Attribute Values....................................................................................17 HTML Attributes Reference................................................................................18 Chapter 5: HTML Headings, Rules, & Comments........................................19 HTML Headings.................................................................................................19 HTML Rules (Lines)...........................................................................................20 HTML Comments..............................................................................................21 Viewing HTML Source Code..............................................................................22 HTML Tag reference...........................................................................................22 V Table of Contents Chapter 6: HTML Paragraphs.......................................................................23 HTML Paragraphs...............................................................................................23 HTML Line Breaks.............................................................................................24 HTML Output Tips............................................................................................24 Complete Tag reference........................................................................................26 Chapter 7: HTML Text Formatting...............................................................27 HTML Formatting Tags......................................................................................27 Text Formatting ..................................................................................................28 Preformatted Text................................................................................................29 "Computer Output" Tags....................................................................................30 Address................................................................................................................31 Abbreviations and Acronyms...............................................................................32 Text Direction......................................................................................................33 Quotations...........................................................................................................34 Deleted and Inserted Text....................................................................................35 Text Formatting Tags...........................................................................................36 Chapter 8: HTML Styles...............................................................................39 The HTML Style Attribute..................................................................................39 Deprecated Tags and Attributes............................................................................40 Common HTML Styles.......................................................................................41 Complete Tag reference........................................................................................44 Chapter 9: HTML Links...............................................................................45 HTML Links.......................................................................................................45 Open a Link in a New Browser Window.............................................................46 Hyperlinks, Anchors, and Links...........................................................................47 HTML Link Syntax.............................................................................................47 Links on the Same Page.......................................................................................50 Creating a mail to: Link.......................................................................................52 Creating an Image Link.......................................................................................54 Chapter 10: HTML Images..........................................................................55 img Tag and the src Attribute...............................................................................55 Insert Images from Different Locations................................................................57 Background Images .........................................................................................58 Aligning Images...................................................................................................59 Floating Images....................................................................................................61 VI Table of Contents Adjusting Image Sizes..........................................................................................62 alt Attribute.........................................................................................................63 Creating an Image Map.......................................................................................63 Chapter 11: HTML Tables...........................................................................65 Creating HTML Tables.......................................................................................65 Table Borders.......................................................................................................68 Table with No Border..........................................................................................70 Headings in a Table..............................................................................................71 Table with a Caption...........................................................................................74 Cells Spanning Multiple Columns.......................................................................75 Tags Inside a Table...............................................................................................76 Cell Padding........................................................................................................78 Cell Spacing.........................................................................................................79 Table Background Colors and Images..................................................................80 Cell Background Colors and Images....................................................................82 Frame Attribute...................................................................................................84 Using frame and border to Control Table Borders................................................88 Chapter 12: HTML Lists..............................................................................90 Unordered Lists...................................................................................................90 Ordered Lists.......................................................................................................93 Definition Lists....................................................................................................95 Nested Lists.........................................................................................................96 Chapter 13: HTML Forms & Input.............................................................99 Forms..................................................................................................................99 Input Tag and Attributes....................................................................................100 Action Attribute.................................................................................................106 Form Examples .................................................................................................106 Chapter 14: HTML Color..........................................................................111 Color Values......................................................................................................111 16 Million Different Colors...............................................................................112 Web Standard Color Names...............................................................................113 Color Names Supported by All Browsers...........................................................113 Web Safe Colors?...............................................................................................114 Shades of Gray...................................................................................................114 VII Table of Contents Chapter 15: HTML 4.01 Quick List..........................................................116 HTML Basic Document....................................................................................116 Heading Elements..............................................................................................116 Text Elements....................................................................................................116 Logical Styles.....................................................................................................117 Physical Styles....................................................................................................117 Links, Anchors, and Image Elements.................................................................117 Unordered (Bulleted) List..................................................................................117 Ordered (Numbered) List..................................................................................117 Definition list....................................................................................................118 Tables................................................................................................................118 Frames...............................................................................................................118 Forms................................................................................................................118 Entities..............................................................................................................119 Other Elements..................................................................................................119 Section II: HTML/CSS Advanced......121 Chapter 16: HTML Layout........................................................................123 HTML Layout Using Tables..............................................................................123 Chapter 17: HTML Frames........................................................................125 frameset Tag.......................................................................................................125 frame Tag...........................................................................................................127 Designing with Frames......................................................................................128 Chapter 18: HTML Fonts..........................................................................136 font Tag.............................................................................................................136 Font Attributes..................................................................................................137 Controlling Fonts with Styles.............................................................................137 Chapter 19: Why Use HTML 4.0?.............................................................140 VIII HTML 3.2 Was Very Wrong!.............................................................................140 Enter HTML 4.0...............................................................................................140 Table of Contents Chapter 20: HTML CSS Styles...................................................................142 Styles in HTML.................................................................................................142 How to Use Styles..............................................................................................144 Style Tags...........................................................................................................146 Chapter 21: HTML Character Entities.......................................................147 Character Entities..............................................................................................147 Nonbreaking Space............................................................................................148 Commonly Used Character Entities...................................................................149 Chapter 22: HTML Head & Meta Elements..............................................150 Head Element....................................................................................................150 Meta Element....................................................................................................153 Chapter 23: HTML Uniform Resource Locators........................................157 Uniform Resource Locator (URL).....................................................................157 URL Schemes....................................................................................................158 Using Links.......................................................................................................159 Chapter 24: HTML Scripts........................................................................160 Insert a Script into a Page...................................................................................160 How to Handle Older Browsers.........................................................................161 noscript Tag.......................................................................................................162 Script Tags.........................................................................................................162 Chapter 25: HTML Standard Attributes.....................................................163 Core Attributes..................................................................................................163 Language Attributes...........................................................................................163 Keyboard Attributes...........................................................................................164 Chapter 26: HTML Event Attributes.........................................................165 Window Events.................................................................................................165 Form Element Events.........................................................................................166 Keyboard Events................................................................................................166 Mouse Events.....................................................................................................166 Chapter 27: HTML URL Encoding...........................................................167 URL Encoding..................................................................................................167 Common URL Encoding Characters.................................................................168 IX Table of Contents Chapter 28: Turn Your PC Into a Web Server.............................................169 Your Windows PC as a Web Server....................................................................169 Installing IIS on Windows Vista and Windows 7...............................................170 Installing IIS on Windows XP and Windows 2000............................................171 Testing your Web...............................................................................................171 Your Next Step: A Professional Web Server........................................................172 Chapter 29: HTML and CSS Summary.....................................................173 Section III: Appendixes....................175 Appendix A: HTML 4.01 1.0 Reference.............................................177 Appendix B: HTML Standard Attributes............................................185 Appendix C: HTML Standard Event Attributes..................................187 Appendix D: HTML Elements and Valid Doctypes............................189 Appendix E: HTML Character Sets....................................................193 Appendix F: HTML ASCII Reference.................................................196 Appendix G: HTML ISO-8859-1 Reference.......................................201 Appendix H: Symbol Entities Reference..............................................207 Appendix I: HTML URL Encoding Reference....................................213 X Introduction W elcome to Learn HTML and CSS with w3schools. This book is for Web users learning to create their own Web pages using HTML, the standard tagging language for the World Wide Web. w3schools (www.w3schools.com) is one of the top Web destinations to learn HMTL and many other key Web languages. w3schools’ tutorials are recommended reading in more than 100 universities and high schools all over the world. This book is a great companion to the HTML and CSS tutorials on the w3schools site, which were written by Hege Refsnes, Ståle Refsnes, Kai Jim Refsnes, and Jan Egil Refsnes. Like the w3schools online tutorials, this book features a brief presentation of each topic, trading lengthy explanations for abundant examples showcasing each key feature. This book, as well as other w3schools books published by Wiley, features straightforward and concise tutorials on each topic from which the beginning Web developer can easily learn. All of the book’s content is derived from w3schools’ accurate, user-tested content used by millions of learners every month. HTML With HTML, you can create your own Web site. HTML is the core technology in which all Web pages are written. This tutorial teaches you everything about HTML. HTML is easy to learn—you will enjoy it. What You Should Already Know Before you continue, you should have a basic understanding of how to use a browser to view pages on the Web. If you want to study these subjects first, please read The Internet For Dummies, 12th Edition, also from Wiley Publishing. What is HTML? HTML is a language for describing Web pages. 8 HTML stands for HyperText Markup Language. 8 HTML is not a programming language, it is a markup language. 8 A markup language is a collection of markup tags. 8 HTML uses markup tags to describe Web pages. 1 Learn HTML and CSS with w3schools What are Tags? 8 HTML markup tags are usually called HTML tags or just tags. 8 HTML tags are keywords surrounded by angle brackets like . 8 HTML tags normally come in pairs, like and . 8 The first tag in a pair is the start tag; the second tag is the end tag. 8 Start and end tags are also called opening tags and closing tags. HTML Documents = Web Pages 8 HTML documents describe Web pages. 8 HTML documents contain HTML tags and plain text. 8 HTML documents are also called Web pages. The purpose of a Web browser (like Internet Explorer or Mozilla Firefox) is to read HTML documents and display them as Web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page. In your browser, it looks like figure I.1.

My First Heading

My first paragraph

In the previous code example, 8 The text between and describes the Web page. 8 The text between and is the visible page content. 8 The text between

and

is displayed as a heading. 8 The text between

and

is displayed as a paragraph. Figure I.1 2 Introduction How to Use This Book Throughout this book, you will see several icons: Try it yourself >> The Try It Yourself icon indicates an opportunity for you to practice what you’ve just learned. The code and examples under this icon come from examples on the w3schools site, which allow you to make changes to the code and see the results immediately. You do not have to type the code examples in this book; you can find them all on the w3schools site. The w3schools icon indicates that more information is available on the w3schools site. This icon indicates where you will find further information about a topic that is covered more thoroughly elsewhere within the book. NO T E Notes call your attention to important information you need to know before proceeding. TIP Tips provide you with suggested shortcuts and information to help you be more productive. This book is divided into three sections: 8 Section I: HTML Basic 8 Section II: HTML/CSS Advanced 8 Section III: Appendixes If you’re eager to improve your Web pages and to add some interactivity, jump right in with HTML basics. Plenty of examples and opportunities to try things await, and w3schools will be right there when you need them! 3 Section I HTML Basic ❑ Chapter 1: HTML Getting Started ❑ Chapter 2: HTML Fundamentals ❑ Chapter 3: HTML Elements ❑ Chapter 4: HTML Attributes ❑ Chapter 5: HTML Headings, Rules, & Comments ❑ Chapter 6: HTML Paragraphs ❑ Chapter 7: HTML Text Formatting ❑ Chapter 8: HTML Styles ❑ Chapter 9: HTML Links ❑ Chapter 10: HTML Images ❑ Chapter 11: HTML Tables ❑ Chapter 12: HTML Lists ❑ Chapter 13: HTML Forms & Input ❑ Chapter 14: HTML Colors ❑ Chapter 15: HTML 4.01 Quick List Chapter 1 HTML Getting Started In This Chapter ❑ What You Need ❑ HTML Editors ❑ Create Your Own Test Web ❑ .HTM or .HTML Extension? What You Need It’s simple to get started writing HTML. 8 You don’t need any tools to learn HTML with w3schools. 8 You don’t need an HTML editor. 8 You don’t need a Web server. 8 You don’t need a Web site. HTML Editors In this tutorial, we use a plain text editor (like Notepad) to edit HTML. We believe this is the best way to learn HTML. Instead of writing plain text, however, professional Web developers often prefer using HTML editors like FrontPage or Dreamweaver because they offer code-writing shortcuts and helpful features. 7 Learn HTML and CSS with w3schools Create Your Own Test Web We suggest you experiment with everything you learn in this book by editing your Web files with a text editor (like Notepad) and opening them in Internet Explorer to view the results. To create a test Web on your own computer, just copy the following three files from the w3schools Web site to your desktop. http://www.w3schools.com/html/mainpage.htm http://www.w3schools.com/html/page1.htm http://www.w3schools.com/html/page2.htm After you have copied the files, double-click on the file called mainpage.htm and see your first Web site in action. If your test Web contains HTML markup tags you have not learned, don’t panic. You will learn all about markup tags in the next chapters. .HTM or .HTML Extension? When you save an HTML file, you can use either the .htm or the .html extension. We use .htm in our examples. It is a habit from the past, when the software only allowed three letters in file extensions. In most cases, it is perfectly safe to use .html. The w3schools Web site contains a wealth of helpful tools to help you learn HTML, including hundreds of cut-and-paste examples, an online text editor, an HTML Color Picker, quizzes to test your knowledge, and an abundance of Web-building reference tables. We recommend you refer to the Web site often as you work through this book. http://www. w3schools.com/html 8

Author W3Schools Isbn 9780470611951 File size 19 Mb Year 2010 Pages 240 Language English File format PDF Category Web Development Book Description: FacebookTwitterGoogle+TumblrDiggMySpaceShare It could be more detailed about new types of HTML like XHTML. IT gathers all of the notes they have on their website and gathers them in one place. Overall could be better. A fast, simple tutorial from the leading Web developer instruction site W3Schools.com is the number one online education source for beginning Web developers. This book packages W3Schools content in an attractive two-color design that gets beginning Web developers and designers up and running with the core Web development technologies. To-the-point tutorials with clear examples and simple explanations give novices the knowledge they need to get going with confidence. W3Schools is the top Google search result for instruction on HTML, CSS, and other key Web technologies; this book presents W3Schools tutorials in an easy-to-follow format for quick learning Features a thorough reference section for easy review of such items as lists of tags, attributes, and symbols Covers elements and attributes, headings and paragraphs, formatting and styles, links and images, tables, lists, forms, colors, fonts, frames, entities, head and meta, style sheets, style tags, and more Designed to get beginning Web developers up and running as quickly as possible, Learn HTML and CSS with W3Schools presents a proven, highly focused course of instruction in an easy-to-use format.     Download (19 Mb) Learning Web Design Adaptive Web Design Web Design: A Beginner’s Guide Second Edition CSS for Beginners – Learn to Tweak Your Website Design HTML, XHTML, and CSS Bible, 5th Edition Load more posts

Leave a Reply

Your email address will not be published. Required fields are marked *