×

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 Layouts

HTML Layouts HTML templates provide a way for well-managed, well-structured responsive web pages to be organized. We could say that the HTML layout specifies how web pages can be set up....

4 minutes read.

HTML Audio

HTML AUDIO: HTML5 provides a method to embed the audio file into a webpage by using HTML5. Before HTML5 audio files is used to play on the browser with the help of...

1 minute read.

HTML <section> tag

The section element in HTML is used to define sections in a document. Syntax of Section Tag: <body> <h1>……….</h1> <section> <h2>……….</h2> <p> …………………………</p> </section> <section> <h2>………..</h2> <p>…………………………. <p> </section> </body> Examples of Section Tag Example 1: In this example, we use the HTML "section" element...

3 minutes read.

HTML <address> Tag

Hyper Text Markup Language, HTML is the best markup language for creating Web pages. HTML consists of a wide variety of elements. In all of these elements, one element is...

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

HTML Canvas: Using JavaScript, the < canvas > tag in HTML is used for drawing graphics on web page. It can be used to draw routes, boxes, text, gradient, and...

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

Introduction This HTML tutorial helps beginners and professionals to learn HTML easily. HTML is a widely used web technology for website development. It stands for Hyper Text Markup Language. It is mainly used to...

7 minutes read.

Difference between HTML and DHTML

Introduction to HTML HTML stands for Hypertext Markup Language. It is a standard web language used to create web pages and applications. HTML is used to define the structure and content...

4 minutes read.

HTML Nested Table

HTML nested table refers to a table that is created inside another table. The table is in the form of rows and columns. From left to right are called horizontal rows,...

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

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.

How to add Google Translate Button on your Webpage?

Google translator is a multi-language translator used for translating the webpage. Google develops it. In today's digital age, it is essential because information is available worldwide in some specific language...

5 minutes read.

HTML Ordered List

We use <ol> tag to make an ordered list in html. An ordered list is made to make a list of items in ordered form, ordered list can be either...

3 minutes read.

HTML Links

It consist of anchor element which is used to create a link between a source anchor and destination anchor. The anchor tag can be embedded between text, image, video or...

2 minutes read.

HTML Text Format

Introduction HTML may format text in two different ways. The HTML tags define a text property to make it appear one way or another. A text element may also be formatted...

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

<object> element: It embed the object within the HTML documents and embed plug-ins such as Java applets, PDF readers, Flash Players etc in web pages. Example: <object width="100" height="100" data="bookmark.swf"></object> <embed> element: It defines an embedded...

1 minute read.

HTML <source> tag

For media attributes, such as <video> tag, <audio> tag, and <picture> tag, we use the <source> tag in html for adding such type of multiple media html elements in our...

4 minutes read.