Links and Comments in HTML5

Slides:



Advertisements
Similar presentations
3.02D HTML Overview 3.02 Develop webpages.
Advertisements

XP 1 Developing a Basic Web Site Tutorial 2: Web Site Structures & Links.
Developing a Web Site: Links Using a link is a quicker way to access information at the bottom of a Web page than scrolling down A user can select a link.
In this lecture, you will learn: ❑ How to link between pages of your site ❑ How to link to other sites ❑ How to structure the folders on your web site.
HTML5 and CSS3 Illustrated Unit E: Inserting and Working with Links
External Site Links by Awnya Boam. Links are found… …almost everywhere on the internet. They allow users to travel from one site to another.
Links and Comments.
XP Adding Hypertext Links to a Web Page. XP Objectives Create hypertext links between elements within a Web page Create hypertext links between Web pages.
Announcement #1 1 Lecture 9. Announcement #2  Midterm exam will be on Oct. 12 (Tuesday)  pm – 1.45 pm  Exam will cover all materials till Oct.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
HTML Tags. Objectives Know the commonly used HTML tags Create a simple webpage using the HTML tags that will be discussed.
Shows the entire path to the file, including the scheme, server name, the complete path, and the file name itself. Same idea of stating your full name,
Links in HTML. Hyperlinks or links Millions of linked web pages make up the World Wide Web Used to connect a web page to another web page on the same.
Basic HTML Hyper text markup Language. Re-cap  … - The tag tells the browser that this is an HTML document The html element is the outermost element.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
WEB DESIGN USING DREAMWEAVER. The World Wide Web –A Web site is a group of related files organized around a common topic –A Web page is a single file.
Informatics Computer School CS114 Web Publishing HTML Lesson 2.
Hyperlinks. Linking pages…Hyperlinks 2 Lecture 8  Hyperlink “A clickable HTML element that will direct the web browser to display a different Web page.
Adding Hyperlinks To a Web Page. Hyperlink and Its Add-Ons Main way to connect web pages and move throughout a web site. Uses the Anchor Tag which is.
Web Design (5) Navigation (1). Creating a new website called ‘Navigation’ In Windows Explorer, open the folder “CU3A Web Design Group”; and then the sub-folder.
XP 1 New Perspectives on Creating Web Pages with HTML Adding Hypertext Links to a Web Page.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 4: Creating Hyperlinks Kelly L.
Unit 1 — HTML BASICS Lesson 2 — HTML Organization Techniques.
Section 4.1 Format HTML tags Identify HTML guidelines Section 4.2 Organize Web site files and folder Use a text editor Use HTML tags and attributes Create.
XP Dreamweaver 8.0 Tutorial 3 1 Adding Text and Formatting Text with CSS Styles.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
1.  Use the anchor element to link from page to page  Configure absolute, relative, and hyperlinks  Configure relative hyperlinks to web pages.
Unit 3 Day 6 FOCS – Web Design. Journal Unit #3 Entry #4 Write the source code that would make the following display on a rendered page: Shopping List.
Creating Links. The Anchor Element: The anchor tag can be used in three different ways: 1.External link – to link to a web page outside your own website.
HTML BTEC National in Computing Section5. Create Information “HTML: defining HTML, discussing HTML uses and demonstrating HTML basics, HTML structure…..
XP 1 HTML Tutorial 2: Developing a Basic Web Site.
Tutorial 3 Adding and Formatting Text with CSS Styles.
Chapter 6 Links. 3 Parts of Links 1. Destination: defines what happens when a user clicks the link. 2. Label: this is the text (or possibly an image)
HTML Basics. HTML Coding HTML Hypertext markup language The code used to create web pages.
Links in HTML What you need to know….. Hyperlinks or links Millions of linked web pages make up the World Wide Web Used to connect a web page to another.
HTML Links HTML uses a hyperlink to another document on the Web.
Developing a Basic Web Site HTML Tutorial 2. Objectives Define links and how to use them. Create element ids to mark specific locations within a document.
Session: 4. © Aptech Ltd. 2Creating Hyperlinks and Anchors / Session 4  Describe hyperlinks  Explain absolute and relative paths  Explain how to hyperlink.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 2 Key Concepts 1 Copyright © Terry Felke-Morris.
HTML And the Internet. HTML and the Internet ► HTML: HyperText Markup Language  Language in which all pages on the web are written  Not Really a Programming.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 2 Creating Links.
Hyperlinks Links for Other Pages. Hyperlink (aka Link) Text (or image) user can click Takes user to different location In general, location can be: On.
HTML5 and CSS3 Illustrated Unit E: Inserting and Working with Links.
HTML Links CS 1150 Spring 2017.
HTML Basics.
Objective % Select and utilize tools to design and develop websites.
Section 4.1 Section 4.2 Format HTML tags Identify HTML guidelines
Bare boned notes.
Learning the Basics – Lesson 1
Links and Comments.
Creating Links.
Tutorial 8 Designing a Web Site with Frames
Objective % Select and utilize tools to design and develop websites.
CS7026: Authoring for Digital Media HTML Authoring
Hyperlinks, Images and Tables
Inserting and Working with Links
CNIT 131 HTML5 – Anchor/Link.
Links and Comments.
Tutorial 8 Designing a Web Site with Frames
HTML Introduction Lecture 8.
Creating Links.
Hyperlinks, Images and Tables
Enhancing Your Web Site—Adding Links Web Page
Links and Comments.
Links and Comments.
IDT Links in HTML What you need to know….
HTML Links CS 1150 Fall 2016.
Creating Links.
Presentation transcript:

Links and Comments in HTML5

The <a> Element The <a> element ("anchor") is used to create a clickable link to another location. There are five varieties of links: External link – to a web page outside our own website. Internal link – to another web page on our own website. Bookmark link – to a specific position within the current web page. Download link - to specify that the target file will be downloaded when a user clicks on the hyperlink. Email link - to automatically start a new email message. We will learn how the <a> element works and take a look at examples of each of these link types, but first let's learn about element attributes.

Element Attributes Attributes add information to an element and often control how an element is displayed on the page. Here is the <a> element with two attributes defined: <a href="http://www.google.com" target="_blank">look it up on Google</a>. attribute attribute attribute value attribute value Each element has its own set of attributes available. Usually these attributes are optional, but in some cases they are mandatory. As in this example, an element can have multiple attributes applied to it at the same time. Attribute names should be in lowercase and attribute values should be enclosed in quotes.

Using the <a> Element Whatever text is placed between the <a> and </a> tags will display on the web page and become a clickable link. This is often referred to as anchor text: <body> <p>If you're uncertain, just <a href="http://www.google.com" target="_blank">look it up on Google</a>. </p> </body> The href attribute ("hypertext reference") instructs the browser which page to load if the link is clicked. The target attribute is optional and controls how the linked page will be displayed in the browser. If omitted, the new page will load in the existing browser window. If target="_blank" is specified, the linked page will open up and display in a new browser tab or window.

Example: External Link The code we just used is an example of an external link. If clicked, it will take the visitor to a website external from our own site. In this case, the user will go to Google's home page: <a href="http://www.google.com" target="_blank">look it up on Google</a> In order for an external link to function, we must use the full URL ("Uniform Resource Locator") address, including the initial "http://". For long URLs, it's a good idea to copy and paste the URL address directly from the browser rather than trying to type it in to the code window and risk making a mistake. An external link is the most common place to use the target="_blank" attribute. With it set, visitors who click on the link will see the linked page in a new tab, leaving the original tab, showing our web page, still open. If we omit this attribute, visitors who click the link will depart our website entirely. Remember, attribute names should always be in lowercase and attribute values should always be enclosed in quotes for better readability, and error free coding.

Example: Internal Link To create an internal link to another page on our site, we use the same format but just type the file name directly into the href attribute: <a href="page2.html">Go to Page 2</a> The web server will assume that this file is located in the same folder as the current page. If the linked page were located somewhere else, we would need to include a path to that location. We'll learn more about paths in an upcoming lesson. The target="_blank" attribute is usually omitted for links within our own site. We want the existing window to move to the new page. Otherwise, we would clutter up the browser window with multiple tabs, each containing a different page from our site. Internal links like these are how we build a navigation menu to allow our visitors to move from page to page on our site.

Example: Bookmark Link A bookmark link is a link to another location within the existing web page. This special link is created using two separate <a> elements. The first one establishes the link by using an href attribute of "#" (pound sign) followed by the name of the destination anchor: <a href="#end">Click here to go to the conclusion.</a> … <a id="end">Conclusion</a> The second <a> element names the destination anchor by using the id attribute. Since it does not include the href attribute, this <a> element does not create a clickable link and will be invisible to the visitor. The destination anchor does not have to come after the link anchor and can be located anywhere on the page. Bookmark links like these are most commonly used to build a clickable table of contents within a page. The id attribute can be used with any HTML tag to specify a unique id for an element. The value must always be unique within the HTML document.

Example: Download Link The code snippets below are examples of download links. If clicked, they will download the specified target instead of viewing in the browser: <a href="http://www.example.com/files/sample.jpg" download>Click here to download image.</a> The download attribute. URL of specified file to be downloaded. This link will download a file named sample.jpg when clicked. <a href="http://www.example.com/files/sample.jpg" download="newname.jpg">Click here to download image.</a> The download attribute. This is the download attribute value. By specifying a value to the download attribute, we can change the filename of the image that is downloaded to one that we prefer. In this case, newname.jpg. Adding the download attribute will always cause a file to be downloaded rather than viewed in the browser.

Example: Email Link To create a link that automatically starts a new email message, we use mailto: in the href attribute instead of a web page address: <body> <p>If you like my site, please <a href="mailto:me@domain.com">send me an email!</a> </p> </body> When the link is clicked, the visitor's default email application is launched and a new message created. The destination email address is required.

HTML Comments We can add personal comments throughout our web pages. These will not appear on our live web pages. Some typical reasons to add comments are: To make notes to ourselves explaining the purpose of certain lines of code. To indicate to fellow team members where future changes or improvements will go. To inform future programmers about how the page works and of any known pitfalls with modifying content. Memory fades over time and it can be a time-consuming chore to "get back up to speed" on a page written months or years ago. Comments can make things much easier for your collaborators or your future self.

Comment Syntax Comments begin with "<!--" Comments end with "-->" <!-- This is a comment. --> <p>To visit Yahoo's home page, click here:</p> <!-- This next link was set up to open in a new window because some visitors could not find their way back to my website. --> <a href="http://www.yahoo.com" target="_blank">Yahoo!</a> The browser will consider everything between the <!-- and the --> as part of the comment and will therefore disregard it. Comments can span multiple lines, as line breaks and spaces make no difference. WARNING: Be careful what you write! Although comments are not displayed on the live web page, they are still in the web document and can be seen by any user who knows how to view the original source code of a website.

Viewing Source in Microsoft Edge In Microsoft Edge, use the F12 key to view source on a webpage. The source code for this page. The source of a webpage is the same type of code that you are learning to write in this class.

Viewing Source in Chrome Other browsers that allow you to view source by right clicking a page and selecting ‘view source’ from a menu include Firefox, Opera and Safari. All web browsers have the ability to view the underlying code that creates a web page. In Chrome, shown above, a user can see the code in a separate window by right clicking directly on the web page and choosing "View page source." Notice that it displays our comments and colors them green.