LAB 2 INTRODUCTION TO HTML

Similar documents
HTML 1: Overview. Chapter 2

HTML 1: Overview. Chapter 2

c122jan2714.notebook January 27, 2014

CPET 499/ITC 250 Web Systems. Topics

Review of HTML. Chapter Pearson. Fundamentals of Web Development. Randy Connolly and Ricardo Hoar

INTRODUCTION TO WEB USING HTML What is HTML?

1. The basic building block of an HTML document is called a(n) a. tag. b. element. c. attribute. d. container. Answer: b Page 5

HTML CS 4640 Programming Languages for Web Applications

Management Information Systems

CSS 1: Introduction. Chapter 3

Web Publishing Basics I

INTRODUCTION TO HTML5! HTML5 Page Structure!

c122sep814.notebook September 08, 2014 All assignments should be sent to Backup please send a cc to this address

Basics of Web Design, 3 rd Edition Instructor Materials Chapter 2 Test Bank

Programmazione Web a.a. 2017/2018 HTML5

Title: Sep 12 10:58 AM (1 of 38)

Unit 5 Web Publishing Systems Page 1 of 13 Part 4 HTML Part 4

HTML. Hypertext Markup Language. Code used to create web pages

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

More about HTML. Digging in a little deeper

CHAPTER 2 MARKUP LANGUAGES: XHTML 1.0

11. HTML5 and Future Web Application

HTML5 & CSS 8 th Edition. Chapter 2 Building a Webpage Template with HTML5

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 1

This document provides a concise, introductory lesson in HTML formatting.

CSC 121 Computers and Scientific Thinking

BASICS OF WEB DESIGN CHAPTER 2 HTML BASICS KEY CONCEPTS

HTML Hyper Text Markup Language

CHAPTER 1: GETTING STARTED WITH HTML CREATED BY L. ASMA RIKLI (ADAPTED FROM HTML, CSS, AND DYNAMIC HTML BY CAREY)

MPT Web Design. Week 1: Introduction to HTML and Web Design

HTML+ CSS PRINCIPLES. Getting started with web design the right way

Web Development & Design Foundations with HTML5 & CSS3 Instructor Materials Chapter 2 Test Bank

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

recall: a Web page is a text document that contains additional formatting information in the HyperText Markup Language (HTML)

A Balanced Introduction to Computer Science, 3/E

Hyper Text Markup Language

HTML Overview. With an emphasis on XHTML

Web Design and Development ACS Chapter 3. Document Setup

Creating Web Pages Using HTML

CMPT 165 Unit 2 Markup Part 2

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

Html basics Course Outline

Hyper Text Markup Language

Introduction, Notepad++, File Structure, 9 Tags, Hyperlinks 1

Authoring World Wide Web Pages with Dreamweaver

The Structure of the Web. Jim and Matthew

HyperText Markup Language (HTML) is the language of the web. When

Beginning Web Site Design

CSI 3140 WWW Structures, Techniques and Standards. Markup Languages: XHTML 1.0

1.264 Lecture 12. HTML Introduction to FrontPage

MODULE 2 HTML 5 FUNDAMENTALS. HyperText. > Douglas Engelbart ( )

Full file at New Perspectives on HTML and CSS 6 th Edition Instructor s Manual 1 of 13. HTML and CSS

Certified HTML5 Developer VS-1029

How the Internet Works

The internet is a worldwide collection of networks that link millions of computers. These links allow the computers to share and send data.

PESIT Bangalore South Campus

CAS 111D: XHTML Tutorial

Desire2Learn: HTML Basics

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

Introduction to HTML5

Web Development and Design Foundations with HTML5 8th Edition

Introduction to HTML

Announcements. Paper due this Wednesday

E-Business Systems 1 INTE2047 Lab Exercises. Lab 5 Valid HTML, Home Page & Editor Tables

Chapter W Solutions Authoring Your Own Website

What is XHTML? XHTML is the language used to create and organize a web page:

Web Development & Design Foundations with XHTML. Chapter 2 Key Concepts

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM Advanced Internet Technology Lab.

Anatomy of an HTML document

A Brief Introduction to HTML

Markup Language. Made up of elements Elements create a document tree

Web Programming Week 2 Semester Byron Fisher 2018

Site Owners: Cascade Basics. May 2017

FIT 100 LAB Activity 3: Constructing HTML Documents

CMT111-01/-M1: HTML & Dreamweaver. Creating an HTML Document (Continued)

DREAMWEAVER QUICK START TABLE OF CONTENT

FileNET Guide for AHC PageMasters

Hyper Text Markup Language HTML: A Tutorial

introduction to XHTML

HYPERTEXT MARKUP LANGUAGE ( HTML )

Tutorial 1: HTML Tutorial (Windows Version) HTML (Hypertext Markup Language) Basics Objectives

Web Development & Design Foundations with HTML5 & CSS3 Instructor Materials Chapter 2 Test Bank

Understanding this structure is pretty straightforward, but nonetheless crucial to working with HTML, CSS, and JavaScript.

Web Design 101. What is HTML? HTML Tags. Web Browsers. <!DOCTYPE html> <html> <body> <h1>my First Heading</h1> <p>my first paragraph.

1/6/ :28 AM Approved New Course (First Version) CS 50A Course Outline as of Fall 2014

Dreamweaver Basics Workshop

Beginning HTML. The Nuts and Bolts of building Web pages.

HTML/CSS Lesson Plans

7300 Warden Avenue, Suite 503 Markham, Ontario Canada L3R 9Z6. Phone: Toll Free: Fax:

AGENDA :: MULTIMEDIA TOOLS :: (1382) :: CLASS NOTES

Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5

Downloads: Google Chrome Browser (Free) - Adobe Brackets (Free) -

EPiServer Content Editor s Guide

I-5 Internet Applications

Web Designing HTML5 NOTES

Adobe Dreamweaver CS5/6: Learning the Tools

Content Management System User Training

Lab Chapter 3: Adding Structure to an HTML Page Habitat for Humanity

HTML, XHTML, and CSS 8/21/2011. Chapter Objectives. Chapter 4. Chapter Objectives. Chapter Objectives

Transcription:

LAB 2 INTRODUCTION TO HTML What You Will Learn How to create HTML documents Basic HTML structure How to creating hyperlinks How to add images to a web page HTML5 semantic tags Approximate Time The exercises in this lab should take approximately 30 minutes to complete. Fundamentals of Web Development Randy Connolly and Ricardo Hoar Textbook by Pearson http://www.funwebdev.com

2 Lab 2: Introduction to HTML QUICK TOUR OF HTML P REPARING D IRECTORIES 1 If you haven t done so already, create a folder in your personal drive for all the labs for this book. 2 From the main labs folder (either downloaded from the textbook s web site using code provided with book or in a common location provided by your instructor), copy the folder titled lab02 to your course folder created in step one. Now we are ready to create our first web page. E XERCISE 2.1 F IRST W EB P AGE 1 Using some type of text or HTML editor (such as Notepad, Notepad++, PSPad, etc), type in the following: <!DOCTYPE html> <title>a Very Small Document</title> <p>this is a simple document with not much content Note: these labs use the convention of red bolded text to indicate content to change/enter. 2 Save the file as lab02 exercise01.html in the lab02 folder on your personal drive (the folder you just created in the Preparing Directories step above). 3 Start up FireFox, Chrome, Internet Explorer or some other browser. Open the file lab02 exercise01.html. To do this, you could use the Open command in the menu, drag-anddrop the file from the file manager of the operating system, or double-click the file from the operating system file manager. This will display the file created in step one in the browser window. 4 Switch back to your text editor. Position the cursor before This is a simple and then press Enter three times. Position cursor after the word much. Press space five times. 5 Save the changes and then switch back to browser. Refresh the page. Notice that the browser ignores extra spaces and paragraph returns. 6 Remove the extra spaces and returns added in step 4. Save changes.

Fundamentals of Web Development 3 EXERCISE 2.2 A DDITIONAL S TRUCTURE T AGS 1 Create a new HTML document with the following content: <!DOCTYPE html> <html> <head lang="en"> <meta charset="utf 8"> <title>share Your Travels New York Central Park</title> </head> <body> <h1>share Your Travels</h1> <h2>new York Central Park</h2> <h3>description</h3> <p>photo by Randy Connolly <p>this photo of Conservatory Pond in Central Park New York City was taken on October 22, 2011 with a Canon EOS 30D camera. <h3>reviews</h3> <div> <p>by Ricardo on September 15, 2012 <p>easy on the HDR buddy. </div> <hr/> </body> </html> Notice that this document has additional structure tags (<head>, <body>, <html>) that were required in XHTML but are now optional in HTML5. 2 Save your file as lab02 exercise02.html and test file in browser. The result should look similar to that shown in Figure 2.1. Figure 2.1 Exercise 2 Complete Copyright 2014 Randy Connolly and Ricardo Hoar

4 Lab 2: Introduction to HTML EXERCISE 2.3 M AKING M ISTAKES 1 Open lab02 exercise03.html (which has the same content as the last exercise). 2 Before the text Conservatory (in the second paragraph tag), add the tag <randy>. 3 Save and then test in browser. After testing, remove the <randy> tag. Sadly there is no <randy> tag in HTML. Your browser will simply ignore any tag it does not recognize. 4 Remove the trailing </h1> end tag, save and then test. Since the <h1> tag is never closed, the browser assumes that the content after it should continue being displayed as a first-level heading. 5 Put back the trailing </h1> end tag (i.e., after Share Your Travels ). 6 Change the <h1> tag to <H1>, save and then test. Notice that HTML5 is case insensitive. LINKING Hyperlinks are an essential feature of any web page. Links are created via the anchor (<a>) element. EXERCISE 2.4 L INKING 1 Open lab02 exercise05.html and add the following bolded text: <p>this photo of Conservatory Pond in <a href="http://www.centralpark.com/">central Park</a> in New York City was taken on October 22, 2011 with a Canon EOS 30D camera. This will create an external link. 2 Save changes and test in browser. 3 Modify the document by adding the following link and test. <p>this photo of Conservatory Pond in <a href="http://www.centralpark.com/">central Park</a> in <a href="newyork.html">new York City</a> was taken on October 22, 2011 with a Canon EOS 30D camera. This will create a relative link (i.e., a link to another page in the same web site).

Fundamentals of Web Development 5 ADDING IMAGES E XERCISE 2.5 A DDING I MAGES 1 Add the following tag and then test: <img src="images/central park.jpg" alt="central Park" /> <h3>reviews</h3> This instructs the browser to display the file central park.jpg which is found in the images subfolder. 2 Modify the image tag as follows and test (be sure to move your mouse over the image). <img src="images/central park.jpg" alt="central Park" title="central Park" /> The title attribute is used to display a tooltip; Internet Explorer, also displays the content of the alt attribute in a tooltip if there is no title attribute specified. 3 Change the src attribute to the following (i.e., add a slash before the folder name) and test. <img src="/images/central park.jpg" alt="central Park" title="central Park" /> You will no longer see the central park image. Why? Because the root reference does not work when tested locally. Also, depending on the browser, you may or may not see a missing image icon, as shown in Figure 2.2. Notice that all three of the browsers in the Figure 2.2 will also display the alt attribute, but Firefox does not display a missing image icon. What would we see in Firefox if the missing <img> did not have an alt attribute defined? The answer is nothing. While this makes sense perhaps from an end-user perspective, from a developer s perspective this behavior can be frustrating. This is one of the many reasons why we strongly recommend testing your pages in multiple browsers. Copyright 2014 Randy Connolly and Ricardo Hoar

6 Lab 2: Introduction to HTML Figure 2.2 Missing image indication in different browsers 4 Remove the slash added in step 3. 5 Add the following and then test: <a href="images/large central park.jpg"> <img src="images/central park.jpg" alt="central Park" /> </a> This turns the Central Park image into a link (in this case, a link to a larger version of the Central Park image). 6 Add the following after the Central Park image: <a href="images/large central park.jpg"><img src="images/central park.jpg" alt="central Park" title="central Park"/></a> <p>share: <img src="images/social/email_16.png" alt="email this to someone" /> <img src="images/social/rss_16.png" alt="syndicated content" /> <img src="images/social/twitter_16.png" alt="share this on Twitter" /> Notice that images are by default inline content in that they exist in the same flow as text. 7 Remove the returns between each <img> tag, as shown below, and then test. <p>share: <img src="images/social/email_16.png" alt="email this to someone" /><img src="images/social/rss_16.png" alt="syndicated content" /><img src= "images/social/twitter_16.png" alt="share this on Twitter" /> Notice that the browser interprets each (or multiple ones in a row) carriage return in the HTML as a single space, as shown in Figure 2.3.

Fundamentals of Web Development 7 Figure 2.3 Carriage return treated as a space 8 Modify the following and test. <p>share: <br/> The <br/> tag adds a line break. LIST BASICS Lists are a way of organizing information. HTML supports several different types of list: definition lists, ordered lists, and unordered lists. EXERCISE 2.6 M AKING A L IST 1 Open lab02 exercise04.html and add the following bolded text: <body> <h1>share Your Travels</h1> <h2>new York Central Park</h2> <li>description</li> <li>reviews</li> <h3>description</h3> Remember: these labs use the convention of red bolded text to indicate content to change/enter/insert. This will add an unordered list to your page. Notice that it is a lowercase L not the number 1 in these new tags. Also, the indenting shown in the list above doesn t affect the output in the browser. It is added to make the markup more readable for us, the developers. 2 Save and test. 3 Change the and to <ol> and </ol> and then test in browser. This will change the list to an ordered list. 4 Change the list back to an unordered list. Copyright 2014 Randy Connolly and Ricardo Hoar

8 Lab 2: Introduction to HTML It is common practice to create a list of related links. The next exercise demonstrates this technique. E XERCISE 2.7 L INKING WITH L ISTS 1 Continue working with lab02 exercise05.html and add the following to the list and test: <li><a href="#">description</a></li> <li><a href="#">reviews</a></li> Notice the target for the links (i.e., href="#"). The # simply indicates the current page (i.e., it goes nowhere). This is a common technique for showing links whose destinations are not yet known. 2 Modify the list as follows: <li><a href="#description">description</a></li> <li><a href="#reviews">reviews</a></li> These are now references to anchors on the existing page, which we will add in the next step. 3 Add the following anchors to your document as shown below. <li><a href="#description">description</a></li> <li><a href="#reviews">reviews</a></li> <h3 id="description">description</h3> <p>photo by Randy Connolly <p>this photo of Conservatory Pond in <a href="http://www.centralpark.com/">central Park</a> in <a href="newyork.html">new York City</a> was taken on October 22, 2011 with a Canon EOS 30D camera. <h3 id="reviews">reviews</h3> <div> <p>by Ricardo on September 15, 2012 <p>easy on the HDR buddy. </div> 4 Test by clicking on links in bulleted list.

Fundamentals of Web Development 9 HTML5 SEMANTIC ELEMENTS HTML5 introduced a number of new semantic elements that can make your markup more understandable and thus easier to maintain. The next set of exercises introduces several of these elements. E XERCISE 2.8 H EADER AND F OOTER 1 Open lab02 exercise09.html and test. 2 Add the following and test. <body> <header> <h1>share Your Travels</h1> <h2>new York Central Park</h2> <li><a href="#">description</a></li> <li><a href="#">reviews</a></li> </header> You will notice that the browser does not add any formatting or spacing for the <header> element. It is used purely to make our markup more understandable. Later, once we learn CSS, we can give the header a particular look. 3 At the end of our document, add the following and test. <footer> <p>copyright 2013 Share Your Travels </footer> </body> </html> Like the <header> element, the <footer> element has no built in style. Notice as well the character entity, which adds the copyright symbol. 4 Modify the footer as follows and test. <footer> <p><strong>copyright 2013 Share Your Travels</strong> </footer> The <strong> element is an inline text element. 5 Modify the footer as follows and test. <p><em>copyright 2013 Share Your Travels</em> Copyright 2014 Randy Connolly and Ricardo Hoar

10 Lab 2: Introduction to HTML E XERCISE 2.9 N AVIGATION, A RTICLES AND S ECTIONS 1 Open lab02 exercise10.html, add the following and test. <header> <h1>share Your Travels</h1> <h2>new York Central Park</h2> <nav> <li><a href="#">description</a></li> <li><a href="#">reviews</a></li> </nav> </header> <article> <section> <h3>description</h3> <p>photo by Randy Connolly... [content omitted] </section> <section> <h3>reviews</h3> <div> <p>by Ricardo on September 15, 2012 <p>easy on the HDR buddy. </div> <hr/> </section> </article> <footer> Like with the other HTML5 semantic elements, there is no special browser formatting for these elements. They are used purely to make our markup clearer. E XERCISE 2.10 F IGURE AND C APTIONS 1 Open lab02 exercise11.html, view in browser, then add the following to the large image and test. <figure> <a href="images/large central park.jpg"><img src="images/central park.jpg" alt="central Park" title="central Park"/></a> <figcaption>conservatory Pond in Central Park</figcaption> </figure> <p>share: <br/> Here s a surprise there is in fact a little bit of additional browser formatting for the <figure> HTML5 semantic element. Also notice that we are not wrapping the share icon images in a <figure> element. As discussed in the text, the <figure> element should be used only for images (or other content) that is essential but whose position on the page could change. The share icons are not really essential so they are not contained within a <figure>.

Fundamentals of Web Development 11 VALIDATING HTML In the next exercise, we will use an external validation service to verify that our web page contains HTML that is valid according to the HTML5 DTD. E XERCISE 2.11 V ALIDATING HTML 1 Open a browser and go to http://validator.w3.org 2 In the Validate By File Upload tab, click the Browse or Choose File button and choose your lab02 exercise05.html file. 3 Click the Check button. The site should eventually verify that your page is valid (as shown in Figure 2.4). You may or may not get a warning, but some of the warning are relatively unimportant. 4 Remove the closing element, save, and then redo steps 1-3 of this exercise. The page will not be valid and the service may find not one but many errors. At the time of writing, the validator lists the missing element as error number 10. Thus, while a validator can help you find an error in your markup, the error messages do take some interpretation. 5 Put the closing tag back in, save, and re-validate. Figure 2.4 Using a validation service Copyright 2014 Randy Connolly and Ricardo Hoar