HTML Links
Links are found in nearly all web pages. Links allow users to click their way from page to page.
HTML Links – Hyperlinks
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.
Note: A link does not have to be text. A link can be an image or any other HTML element!
Example
This example shows how to create a link to W3Schools.com:
<a href=”https://www.w3schools.com/”>Visit W3Schools.com!</a>

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
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

Button as a Link
To use an HTML button as a link, you have to add some JavaScript code.
JavaScript allows you to specify what happens at certain events, such as a click of a button:
Example
<button onclick=”document.location=’default.asp'”>HTML Tutorial</button>


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.
Example
<a href=”https://www.google.com/html/” title=”Go to Google’s HTML section”>Visit our HTML Tutorial</a>
HTML Images
Images can improve the design and the appearance of a web page.
HTML Images Syntax
The HTML <img>
tag is used to embed an image in a web page.
Images are not technically inserted into a web page; images are linked to web pages. 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
- alt – Specifies an alternate text for the image
Syntax
<img src=”url” alt=”alternatetext“>
The src Attribute
The required src
attribute specifies the path (URL) to the image.
Note: When a web page loads, it is the browser, at that moment, that gets the image from a web server and inserts it into the page. Therefore, make sure that the image actually stays in the same spot in relation to the web page, otherwise your visitors will get a broken link icon. The broken link icon and the alt
text are shown if the browser cannot find the image.

Image Size – Width and Height
You can use the style
attribute to specify the width and height of an image.
Example
<img src=”img_girl.jpg” alt=”Girl in a jacket” style=”width:500px;height:600px;”>
Alternatively, you can use the width
and height
attributes:
Example
<img src=”img_girl.jpg” alt=”Girl in a jacket” width=”500″ height=”600″>
The width
and height
attributes always define the width and height of the image in pixels.
Note: Always specify the width and height of an image. If width and height are not specified, the web page might flicker while the image loads.
Width and Height, or Style?
The width
, height
, and style
attributes are all valid in HTML.
However, we suggest using the style
attribute. It prevents styles sheets from changing the size of images:
Example
<!DOCTYPE html>
<html>
<head>
<style>
img {
width: 100%;
}
</style>
</head>
<body>
<img src=”html5.gif” alt=”HTML5 Icon” width=”128″ height=”128″>
<img src=”html5.gif” alt=”HTML5 Icon” style=”width:128px;height:128px;”>
</body>
</html>

HTML Background Image
A background image can be specified for almost any HTML element.
Background Image on a HTML element
To add a background image on an HTML element, use the HTML style
attribute and the CSS background-image
property:
Example
Add a background image on a HTML element:
<div style=”background-image: url(‘img_girl.jpg’);”>
You can also specify the background image in the <style>
element, in the <head>
section:
