0% found this document useful (0 votes)
4 views8 pages

Understanding HTML Links and Images

Uploaded by

alijnab24jb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Understanding HTML Links and Images

Uploaded by

alijnab24jb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lecture 4

[Link]
HTML Links
Links are found in nearly all web pages. Links allow users to click their
way from page to page. HTML links are hyperlinks. You can click on a link
and jump to another document. When you move the mouse over a link,
the mouse arrow will turn into a little hand. The HTML <a> tag defines a
hyperlink. It has the following syntax:
<a href="url">link text</a>
The most important attribute of the <a> element is the href attribute,
which indicates the link's destination. The link text is the part that will be
visible to the reader. Clicking on the link text, will send the reader to the
specified URL address.
<a href="[Link] [Link]!</a>

[Link]
HTML Links
By default, links will appear as follows in all browsers:

An unvisited link is underlined and blue


A visited link is underlined and purple
An active link is underlined and red

Links can of course be styled with CSS, to get another look!

[Link]
HTML Links - The target Attribute
By default, the linked page will be displayed in the current browser
window. To change this, you must specify another target for the link.
The target attribute specifies where to open the linked document.
The target attribute can have one of the following values:
_self - Default. Opens the document in the same window/tab as it was
clicked
_blank - Opens the document in a new window or tab
_parent - Opens the document in the parent frame
_top - Opens the document in the full body of the window
<a href="[Link] target="_blank">Visit
[Link]!</a>

[Link]
Absolute URLs vs. Relative URLs
absolute URLs always include the domain name of the site with
[Link] Relative links show the path to the file or refer to the file
itself.
<h2>Absolute URLs</h2>
<p><a href="[Link]
<p><a href="[Link]

<h2>Relative URLs</h2>
<p><a href="[Link]">Second page</a></p>
<p><a href="html/[Link]">Third page</a></p>

[Link]
Link to an Email Address
Use mailto: inside the href attribute to create a link that opens the
user's email program (to let them send a new email):
<a href="[Link] email</a>

Link Titles
The title attribute specifies extra information about an element. The
information is most often shown as a tooltip text when the mouse
moves over the element.
<a href="[Link] title="Go to Google">Visit
[Link]!</a>

[Link]
HTML Images
The HTML <img> tag is used to embed an image in a web page. The <img>
tag creates a holding space for the referenced image. The <img> tag is
empty, it contains attributes only, and does not have a closing tag.
The <img> tag has two required attributes:
src - Specifies the path to the image, it could be absolute or relative
alt - Specifies an alternate text for the image
The <img> tag has following syntax:
<img src="url" alt="alternatetext">
you can also use the width and height attributes:
<img src="[Link]" alt="my img" width="500" height="600">

[Link]
Image as a Link
To use an image as a link, put the <img> tag inside the <a> tag:

<a href="[Link]">
<img src="[Link]" alt="HTML tutorial" style="width:42px;height:42px;">
</a>

[Link]

You might also like