Html & Css

2y ago
40 Views
5 Downloads
5.25 MB
100 Pages
Last View : 16d ago
Last Download : 3m ago
Upload by : Tia Newell
Transcription

HTML & CSSDesign and Build WebsitesJon DuckettJohn Wiley & Sons, Inc.

HTML & CSSDesign and build WebsitesPublished byJohn Wiley & Sons, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com 2011 by John Wiley & Sons, Inc., Indianapolis, IndianaISBN: 978-1-118-00818-8Manufactured in the United States of AmericaPublished simultaneously in Canada10 9 8 7 6 5 4 3 2 1No 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 theCopyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher forpermission should be addressed to the Permissions 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 theaccuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties offitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategiescontained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged inrendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professionalperson should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organizationor Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or thepublisher endorses the information the organization or website may provide or recommendations it may make. Further, readers should beaware 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.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 Control Number: 2011932082Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or itsaffiliates, in the United States and other countries, and may not be used without written permission. All other trademarks arethe property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned inthis book.

CreditsFor John Wiley & Sons, Inc.Executive EditorCarol LongAuthorJon DuckettMarketing ManagerAshley ZurcherCover DesignerEmme StoneProduction ManagerTim TateDesign and LayoutJon DuckettEmme StonePhotographyJohn Stewardsonjohnstewardson.comPRODUCTION EDITORDaniel ScribnerVice President andExecutive Group PublisherRichard SwadleyVice President andExecutive PublisherBarry PruettAssociate PublisherJim MinatelProduction Coordinator,CoverKatie CrockerAdditional PhotographyHesperianJoe Robertsonflickr.com/photos/mindfireJules Clancythestonesoup.comTechnical EditorChris MillsKylie Gussetgusset.netMichael StillwellTECHNICAL REVIEWERSAndy StoneAngela ShimellDonna WatsonMartin CallananRob JacobyTony Berrybeebo.org

Try out and download all of the code for this book online at:http://www.htmlandcssbook.com/code/

ContentsIntroductionChapter 1: StructureChapter 2: TextChapter 3: ListsChapter 4: LinksChapter 5: ImagesChapter 6: TablesChapter 7: FormsChapter 8: Extra MarkupChapter 9: Flash, Video & AudioChapter 10: Introducing CSSChapter 11: ColorChapter 12: TextChapter 13: BoxesChapter 14: Lists, Tables & FormsChapter 15: LayoutChapter 16: ImagesChapter 17: HTML5 LayoutChapter 18: Process & DesignChapter 19: Practical 0330358406428452476493

IntroductionXXXXXXAbout this bookHow the web worksLearning from other pages

Firstly, thank you for picking up thisbook. It has been written with two verydifferent types of people in mind: Those who want to learn how to design and build websitesfrom scratch Anyone who has a website (that may be built using acontent management system, blogging software, or ane-commerce platform) and wants more control over theappearance of their pagesThe only things you need in order to use this book are acomputer with a web browser and a text editor (such asNotepad, which comes with Windows, or TextEdit, whichcomes with Macs).3INTRODUCTION

Introduction pages come at the beginning of eachchapter. They introduce the key topics you will learnabout.Reference pages introduce key pieces of HTML &CSS code. The HTML code is shown in blue and CSScode is shown in pink.Background pages appear on white; they explain thecontext of the topics covered that are discussed ineach chapter.Diagram and infographics pages are shown on adark background. They provide a simple, visualreference to topics discussed.Example pages put together the topics you havelearned and demonstrate how they can be appliedin each.Summary pages come at the end of each chapter.They remind you of the key topics that were coveredin each chapter.INTRODUCTION4

Is it hard to Learn?Many books that teach HTML and CSSresemble dull manuals. To make it easier foryou to learn, we threw away the traditionaltemplate used by publishers and redesignedthis book from scratch.At work, when people lookat my screen and see it full ofcode, it's not unusual to get acomment about it looking verycomplicated or how clever I mustbe to understand it. The truthis, it's not that hard to learn howto write web pages and readthe code used to create them;you certainly don't have to be a"programmer."5INTRODUCTIONUnderstanding HTML and CSScan help anyone who workswith the web; designers cancreate more attractive andusable sites, website editors cancreate better content, marketerscan communicate with theiraudience more effectively, andmanagers can commissionbetter sites and get the best outof their teams.I've focussed on the code youneed to use 90% of the timeand omitted the code that youwould rarely see even if writingwebsites is your full time job. Bythe end of the book, if you comeacross the other 10% you will beable to Google it to find out whatit means quickly and easily.I have also added practicalinformation on topics I amcommonly asked about, such ashow to prepare images, audioand video for the web, how toapproach the design and buildof a new site, how to improveyour rankings in search engines(SEO), and how to use GoogleAnalytics to learn about visitorsto your site.

The Structure ofThis BookIn order to teach you about creating web pages,this book is divided into three sections:1: HTML2: CSS3: PracticalWe will spend the first chapterlooking at how HTML is used tocreate web pages. You will seethat you start by writing downthe words you want to appearon your page. You then add tagsor elements to the words sothat the browser knows what isa heading, where a paragraphbegins and ends, and so on.We start this section with achapter that explains how CSSuses rules to enable you tocontrol the styling and layoutof web pages. We then go on tolook at the wide variety of CSSproperties you can use in yourCSS rules. These propertiesgenerally fall into one of twocategories:We end up with some helpfulinformation that will assist you inbuilding better websites.The rest of this sectionintroduces the tags you haveat your disposal to create webpages, grouped into chapters on:text, lists, links, images, tables,forms, video audio and flash, andmiscellaneous elements.Presentation: How to controlthings like the color of text, thefonts you want to use and thesize of those fonts, how to addbackground colors to pages (orparts of a page), and how to addbackground images.I should warn you that theexamples in the first ninechapters are not exciting to lookat, yet they are the foundation ofevery web page. The followingchapters on CSS will show youhow to make your pages look alot more interesting.Layout: How to control wherethe different elements arepositioned on the screen. Youwill also learn several techniquesthat professionals use to maketheir pages more attractive.We look at some new tags thatwill be introduced in HTML5 tohelp describe the structure ofyour pages. HTML5 is the latestversion of HTML (still underdevelopment at the time ofwriting). Before learning aboutthese elements, you need a goodgrasp of how CSS is used tocontrol the design of web pages.There is a chapter that talks youthrough a design process thatyou might like to follow whencreating a new website.Finally, we end up looking attopics that will help you onceyou have built your site, suchas putting it on the web, searchengine optimisation (SEO) andusing analytics software to trackwho comes to your site and whatthey are looking at.INTRODUCTION6

How PeopleAccess the WebBefore we look at the code used to buildwebsites it is important to consider thedifferent ways in which people access the weband clarify some terminology.BrowsersWeb ServersScreen readersPeople access websites usingsoftware called a web browser.Popular examples includeFirefox, Internet Explorer, Safari,Chrome, and Opera.When you ask your browser fora web page, the request is sentacross the Internet to a specialcomputer known as a webserver which hosts the website.Screen readers are programsthat read out the contents of acomputer screen to a user. Theyare commonly used by peoplewith visual impairments.In order to view a web page,users might type a web addressinto their browser, follow alink from another site, or use abookmark.Web servers are specialcomputers that are constantlyconnected to the Internet, andare optimized to send web pagesout to people who request them.Software manufacturersregularly release new versionsof browsers with new featuresand supporting new additionsto languages. It is important,however, to remember thatmany computer owners will notbe running the latest versionsof these browsers. Thereforeyou cannot rely on all visitors toyour site being able to use thelatest functionality offered in allbrowsers.Some big companies run theirown web servers, but it is morecommon to use the services ofa web hosting company whocharge a fee to host your site.In the same way that manycountries have legislationsthat require public buildingsto be accessible to those withdisabilities, many laws havealso been passed that requirewebsites be accessible to thosewith disabilities.You will learn how to tell whichbrowsers visitors use to accessyour website in Chapter 19.7INTRODUCTIONDevicesPeople are accessing websiteson an increasing range of devicesincluding desktop computers,laptops, tablets, and mobilephones. It is important toremember that various deviceshave different screen sizes andsome have faster connections tothe web than others.Throughout this book you willsee several references to screenreaders. These notes will helpensure that the sites you createare accessible to people who usesuch software.It is interesting to note thattechnologies similar to thoseemployed by screen readers arealso being used in other areaswhere people are unable read ascreen, such as when they aredriving or jogging.

How WebsitesAre CreatedAll websites use HTML and CSS, but contentmanagement systems, blogging software, ande-commerce platforms often add a few moretechnologies into the mix.What you seeHow it is CreatedHTML5 & CSS3When you are looking at awebsite, it is most likely thatyour browser will be receivingHTML and CSS from the webserver that hosts the site. Theweb browser interprets theHTML and CSS code to createthe page that you see.Small websites are often writtenjust using HTML and CSS.Since the web was first createdthere have been several versionsof HTML and CSS — eachintended to be an improvementon the previous version.Most web pages also includeextra content such as images,audio, video, or animations andthis book will teach you how toprepare them for use on the weband then how to insert them intoyour web pages.Some sites also send JavaScriptor Flash to your browser, and youwill see how to add JavaScriptand Flash in your web pages.Both of these technologies areadvanced topics that you can goon to learn more about once youhave mastered HTML and CSS, ifyou want to.Larger websites — in particularthose that are updated regularlyand use a content managementsystem (CMS), blogging tools, ore-commerce software — oftenmake use of more complextechnologies on the web server,but these technologies areactually used to produce HTMLand CSS that is then sent to thebrowser. So, if your site usesthese technologies, you will beable to use your new HTML andCSS knowledge to take morecontrol over how your site looks.Larger, more complex sites likethese may use a database tostore data, and programminglanguages such as PHP, ASP.Net,Java, or Ruby on the web server,but you do not need to knowthese technologies to improvewhat the user sees. The skillsyou'll learn in this book should beenough to help you on that road.At the time of writing thisbook, HTML5 & CSS3 werestill being developed. Althoughthey had not been finalized,many browsers were alreadysupporting some features ofthese languages and a lot ofpeople were using the latestcode on their websites. I havetherefore chosen to teach youthese latest versions.Because HTML5 and CSS3build on previous versions ofthese languages, learning thesemeans you will also be able tounderstand the earlier versionsof them. I have added clear noteswhen the code is new and alsowhen it might not work in olderbrowsers.INTRODUCTION8

How the Web WorksWhen you visit a website, the web serverhosting that site could be anywhere in theworld. In order for you to find the location ofthe web server, your browser will first connectto a Domain Name System (DNS) server.On this page you can seeexamples that demonstratehow the web server that hoststhe website you are visiting canbe anywhere in the world. It isthe DNS servers that tell yourbrowser how to find the website. A user in Barcelona visitssony.jp in Tokyo A user in New York visitsgoogle.com in San Francisco A user in Stockholm visitsqantas.com.au in Sydney A user in Vancouver visitsairindia.in in Bangalore9INTRODUCTIONOn the right you can see whathappens when a web user inEngland wants to view thewebsite of the Louvre art galleryin France which is located atwww.louvre.fr. Firstly, thebrowser in Cambridge contactsa DNS server in London. TheDNS server then tells thebrowser the location of the webserver hosting the site in Paris.

21When you connect to the web,you do so via an Internet ServiceProvider (ISP). You type adomain name or web addressinto your browser to visit a site;for example: google.com,bbc.co.uk, microsoft.com .Your computer contacts anetwork of servers calledDomain Name System (DNS)servers. These act like phonebooks; they tell your computerthe IP address associated withthe requested domain name.An IP address is a numberof up to 12 digits separatedby periods / full stops. Everydevice connected to the webhas a unique IP address; it islike the phone number for thatcomputer.Cambridge3The unique number that theDNS server returns to yourcomputer allows your browserto contact the web serverthat hosts the website yourequested. A web server is acomputer that is constantlyconnected to the web, and is setup especially to send web pagesto users.LONDONPARIS4The web server then sends thepage you requested back to yourweb browser.

1StructureXXXXXXUnderstanding structureLearning about markupTags and elements

We come across all kinds of documentsevery day of our lives. Newspapers,insurance forms, shop catalogues. thelist goes on.Many web pages act like electronic versions of thesedocuments. For example, newspapers show the same storiesin print as they do on websites; you can apply for insuranceover the web; and stores have online catalogs and e-commercefacilities.In all kinds of documents, structure is very important in helpingreaders to understand the messages you are trying to conveyand to navigate around the document. So, in order to learn howto write web pages, it is very important to understand how tostructure documents. In this chapter you will:13 See how HTML describes the structure of a web page Learn how tags or elements are added to your document Write your first web pageSTRUCTURE

STRUCTURE14

How Pages UseStructureThink about the stories youread in a newspaper: for eachstory, there will be a headline,some text, and possibly someimages. If the article is a longpiece, there may be subheadingsthat split the story into separatesections or quotes from thoseinvolved. Structure helps readersunderstand the stories in thenewspaper.15STRUCTUREThe structure is very similarwhen a news story is viewedonline (although it may alsofeature audio or video). This isillustrated on the right with acopy of a newspaper alongsidethe corresponding article on itswebsite.Now think about a very differenttype of document — aninsurance form. Insurance formsoften have headings for differentsections, and each sectioncontains a list of questions withareas for you to fill in details orcheckboxes to tick. Again, thestructure is very similar online.

STRUCTURE16

Structuring WordDocumentsThe use of headings andsubheadings in any documentoften reflects a hierarchy ofinformation. For example, adocument might start witha large heading, followed byan introduction or the mostimportant information.17STRUCTUREThis might be expanded uponunder subheadings lower downon the page. When using a wordprocessor to create a document,we separate out the text to giveit structure. Each topic mighthave a new paragraph, and eachsection can have a heading todescribe what it covers.On the right, you can see asimple document in MicrosoftWord. The different styles forthe document, such as differentlevels of heading, are shownin the drop down box. If youregularly use Word, you mighthave also used the formattingtoolbar or palette to do this.

STRUCTURE18

On the previous page you sawhow structure was added toa Word document to make iteasier to understand. We usestructure in the same way whenwriting web pages.19STRUCTURE

HTML Describesthe Structureof PagesIn the browser window you can see a web page that features exactlythe same content as the Word document you met on the page 18. Todescribe the structure of a web page, we add code to the words we wantto appear on the page.You can see the HTML code for this page below. Don't worry about whatthe code means yet. We start to look at it in more detail on the nextpage. Note that the HTML code is in blue, and the text you see on screenis in black. html body h1 This is the Main Heading /h1 p This text might be an introduction to the rest ofthe page. And if the page is a long one it mightbe split up into several sub-headings. p h2 This is a Sub-Heading /h2 p Many long articles have sub-headings so to helpyou follow the structure of what is being written.There may even be sub-sub-headings (or lower-levelheadings). /p h2 Another Sub-Heading /h2 p Here you can see another sub-heading. /p /body /html The HTML code (in blue) is made up of characters that live inside angledbrackets — these are called HTML elements. Elements are usuallymade up of two tags: an opening tag and a closing tag. (The closing taghas an extra forward slash in

Jon DuCkeTT JoHn WiLey & SonS, inC. Published by John Wiley & Sons, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com 2011 by John Wiley & Sons, Inc., Indianapolis, Ind

Related Documents:

History of HTML / CSS HTML 1.0 - 1993 - The Good Old Days - life was simple HTML 2.0 - 1995 - Some interesting layout features - abused CSS 1 - 1996 HTML 3.2 - 1997 HTML 4.0 - 1997 - Layout moving toward CSS CSS Level 2 - 1998 HTML 4.01 - 1999 - What we use today HTML has evolved a *lot* over the years - as computers and networks have gotten faster.

History of HTML / CSS HTML 1.0 - 1993 - The Good Old Days - life was simple HTML 2.0 - 1995 - Some interesting layout features - abused CSS 1 - 1996 HTML 3.2 - 1997 HTML 4.0 - 1997 - Layout moving toward CSS CSS Level 2 - 1998 HTML 4.01 - 1999 - What we use today HTML has evolved a *lot* over the years - as computers and networks have gotten faster.

Intro to HTML / CSS Rachel Starry UrsinusCollege, Tech Play Day May 31, 2018 * HTML Hyper Text Markup Language * HTML is the standard language for creating web pages. What is HTML? HTML Version Year HTML 1991 HTML 2.0 1995 HTML 3.2 1997 HTML 4.01 1999 HTML5 2014 * "HyperText" uses hyperlinks: these allow you

2 Getting Your Tools in Order 23 3 Introducing HTML and CSS 41 PART II: Creating Web Pages 4 Learning the Basics of HTML 57 5 Organizing Information with Lists 71 6 Working with Links 89 PART III: Doing More with HTML and CSS 7 Formatting Text with HTML and CSS 121 8 Using CSS to Style a Site 159 9 Using Images on Your Web Pages 197

CSS is easy to learn and understand but it provides a powerful control over the presentation of an HTML document. Most commonly, CSS is combined with the markup languages HTML or XHTML. Advantages of CSS CSS saves time - You can write CSS once and then reuse the same sheet in multiple HTML pages. You can define a style for each HTML element and

CSS Colorvalues CSS Colornames CSS Tutorial « W3Schools Home Next Chapter » Save a lot of work with CSS! In our CSS tutorial you will learn how to use CSS to control the style and layout of multiple Web pages all at once. CSS Example body {background-color:#d0e4fe;} h1 {color:orange; text-align:center;} p {font-family:"Times New Roman"; font .

A brief history of CSS CSS 3 is divided into several separate documents called "modules" and its notes are posted on W3C: css3-background CSS Backgrounds and Borders Module Level 3 Candidate Rec. Oct 2017 css3-box CSS basic box model Working Draft Jul 2018 css-cascade-3 CSS Cascading and Inheritance Level 3 Candidate Rec. May 2016

4.1 Styling Page Sections 4.1.1 Page Sections (div) 4.1.2 Spans of Text (span) 4.1.3 CSS Context Selectors 4.2 Introduction to Layout 4.2.1 The CSS Box Model 4.2.2 Finding Problems with Firebug 4.3 Floating Elements 4.3.1 The float Property 4.3.2 The clear Property 4.3.3 Making Floating Elements Fit 4.3.4 Multi-Column Floating Layouts 4.4 .File Size: 1MBPage Count: 54Explore furtherCSS Website Layout - W3Schoolswww.w3schools.comHTML Layout Elements and Techniques - W3Schoolswww.w3schools.com15 Free CSS Layouts for User Interface Designers 2022 .colorlib.com50 Free Responsive HTML CSS Templates for 2021www.toocss.com5500 Free HTML Templates, Themes, Codes of 2022 - Mobirisemobirise.com10,000 Free HTML Templates. HTML Website Templatesnicepage.comRecommended to you b