×

HTML Anchor

HTML Anchor

The HTML anchor tags define a hyperlink that links to other pages on one page. It can create hyperlinks to any web page and files, locations or any other URL. "Href" features the most esssential attributes of HTML tags. It also links to the landing page or URL.

href attribute of HTML anchor tag

The href attribute is used to define the address of a file to be added. In other words, the destination page is pointed out.

The HTML anchor tag syntax is given below.

<a href = "..........."> Link Text </a>

Example

<a href="second.html">Click for Second Page</a> 

Code

<html> 
<body> 
<a href="second.html">Click for Second Page</a> 
</body> 
</html> 

Output

HTML Anchor

Specify a location for Link using target attribute

If we want to open any link on another page, we can use the <a> tag . The next page will opened with the help of this link.

Example

<!DOCTYPE html>  
<html>  
<head>  
    <title></title>  
</head>  
<body>  
<p>Click on <a href=" https://www.tutorialandexample.com/" target="_blank"> this-link </a>to go on home page of Tutorialandexample.</p>  
</body>  
</html>

Output

HTML Anchor

Appearance of HTML anchor tag

It will appear in the following way:

  • An unvisited link is displayed underlined and blue.
  • A visited link displayed underlined and purple.
  • An active link is underlined and red.

HTML Image

HTML img tag is used to shows photos on the web page. HTML img tag is an empty tag containing only attributes. The closing tags are not included in the image element of HTML.

Example

<!DOCTYPE>
<html> 
<body> 
<title>My Page</title>
<h2>HTML Image Example</h2> 
<img src="Hello Friend.jpg" alt="Hello Friends"/>
</body> 
</html> 

Output

HTML Anchor

Attributes of HTML img tag

The src and alt are the key attributes of HTML img tag. All HTML image tag attributes are listed below.

Src

It is a necessary attribute that describes the image's source or direction. It instructs the user that where the server will search for the file. The image location can be on the same directory or on a different server.

Alt

If it cannot be displayed, it defines an optional text for the full-featured image. The value of the alt attribute describes the word image. The alt attribute is considered a good prospective SEO attribute.

Width

It is an optional attribute used to specify the image width that can be displayed. Right now, it is not recommended. The CSS should be applied instead of the width attribute.

Height

The height of the image is h3. The height attribute for HTML also supports elements of iframs, images and objects. You should use the height attribute instead of the CSS.

Use of height and width attribute with img tag

You've learned how to insert an image into your web page. We can set the attibutes of height and width to chnage the specifications (height and width) of the image.

Example

<!DOCTYPE html>
<html>
<head>
            <title>Image tag</title>
</head>
<body>
<h2>HTML image example with height and width</h2>
<img src="https://static.tutorialandexample.com/htmlpages/images/animal.jpg" height="180" width="300" alt="animal image">
</body>
</html>

Output

HTML Anchor

Use of alt attributed

Alt attribute can be used with tag. In case the image can not be displayed on browser, it will display an alternative text. The example for alt attribute follows:

Example

<!DOCTYPE html>
<html>
<head>
            <title>Image tag</title>
</head>
<body>
<h2>HTML image example with height and width</h2>
<img src="animal.png" height="180" width="300" alt="animal image">  
</body>
</html>

Output

HTML Anchor

How to get image from another directory/folder?

To insert an image in your web, you must have that image in your same folder where you have placed the HTML file. But if the image is in some other directory, you can access the image like this:

Example

<img src="E:/images/animal.png" height="180" width="300" alt="animal image"> 

Related Topics

HTML <span> tag

The span tag in HTML is used as an inline container element to mark up a specific or special chunk of a text or a section of a page. If you...

2 minutes read.

HTML <select> tag

This tag helps in making the drop-down list on the web page. This is highly used in HTML forms for taking the input from user. You can use the id attribute...

3 minutes read.

Design a tribute page using HTML and CSS

A tribute page is a webpage based on a person who inspired us in our life. In this article, we will create a webpage of Mahatma Gandhi. We are going...

5 minutes read.

HTML Anchor

HTML Anchor The HTML anchor tags define a hyperlink that links to other pages on one page. It can create hyperlinks to any web page and files, locations or any other...

3 minutes read.

HTML <u> tag

Underline Element/Tag: The u tag in html is used to specify the important text or phrase by underline. In earlier HTML versions, this element was known as the "Underline" element, and...

5 minutes read.

HTML <body> tag

HTML means Hyper Text Markup Language, which is most preferred for making Web pages. It explains how a Web page is put together. There are many different elements in HTML,...

3 minutes read.

What does HTML stand for?

HTML stands for Hyper Text Markup Language. We use this markup language to design a web page. Web browsers use this language to showcase text, videos, images, audio and other...

6 minutes read.

Html <colgroup> Tag

A HTML table's column group is specified by the "colgroup" tag. If you want to apply various properties to one or more <col> elements in an HTML table, then you...

4 minutes read.

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag...

4 minutes read.

Html Wbr Tag

The Line Break Opportunity element A word break opportunity is a place in text from where the browser breaks a line. This opportunity is represented by the element wbr in the...

2 minutes read.

HTML Code

Before jumping into the topic, let’s understand a common scenario where we have a code snippet in our HTML file. By code snippet, we mean computer code, which is written...

5 minutes read.

HTML Date

The input element in HTML has several attributes. One of its attributes is the type attribute which creates a calendar in an order that a user can select a date...

5 minutes read.

HTML Event Attributes

HTML Event Attributes If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on...

4 minutes read.

HTML SVG

HTML SVG: SVG stands for Scalable Vector Graphics which defines the graphics for the web. It is a language for describing 2-D graphics in XML. Each drawn shape in SVG is...

1 minute read.

HTML Images

HTML has <img> tag to display image on the web pages or web application. This tag is an empty tag i.e. we don't have to close this tag while using. SYNTAX: <img src="source address" attributes="alt, height, width"> Example: <html>   <body>   <center>Image tag Example</center>   <img src="https://www.tutorialandexample.com/resources/images/favicon.png"    alt="tutorialandexample"/>   </body>   </html> Output: Image...

1 minute read.

HTML Lists

HTML List HTML lists are used to specify data sets. All lists can include one or more elements from the list. HTML lists are available in three different types: Ordered List or...

4 minutes read.

Most Commonly used Tags in HTML

In this tutorial, we'll look at the most popular HTML tags. We know HTML is a fundamental requirement for creating a website. As a result, it is essential to remember...

9 minutes read.

Html &lt;datalist >Tag

The autocomplete feature in HTML files is provided by the <datalist> tag. It can be used in conjunction with an input tag to enable users to quickly fill out form...

4 minutes read.

How to add JavaScript to HTML

JavaScript is one of the most important languages today. It is a high-level, interpreted, lightweight programming language that makes web pages more interactive. It is a language of the web....

5 minutes read.

HTML Font Color

The HTML <font> tag has an attribute called color, which defines the color of the text. We use the color attribute inside the <font> tag to specify the color of...

6 minutes read.