×

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

The titles and subtitles of our webpages are known as HTML headings. Let’s not talk about webpages but giving heading to almost everything like normal paragraphs, articles or let it...

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

How to insert spaces/tabs in text using HTML/CSS

What is HTML? HTML or HyperText Markup Language is used to design web pages. It was released in 1993. The file extension name for HTML file is “.html”. An HTML file...

4 minutes read.

HTML Code Tag

The code tag in HTML is a phrase tag used to insert a piece of computer programming code. In HTML there is a separate tag named as <code> tag. Sometimes,...

3 minutes read.

HTML Elements

An HTML element is nothing but a starting tag and then some content and then the closing tag. So we can say HTML elements is everything from the starting tag...

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

CSS Clearfix

CSS Clearfix: A clearfix (or clear float) in CSS is for a component to clear or fix the child component, so we don’t need to insert additional markup. The clear...

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

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

Font tag in HTML

HTML stands for Hypertext Mark-up Language and is used to create web pages and other information that can be later displayed in a web browser. It also consists of a...

4 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 Basic Tags

Heading Tags: This tag represents the document header. It is said to be a good practice if every document starts with Heading. Heading tags ranges from H1 to H6 i.e....

3 minutes read.

HTML <video> Tag

The Video tag in HTML is used to play video on a media player on the web page. We can also insert an audio by the video tag, but audio...

6 minutes read.

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

HTML Frames

Frames in Html is used to divide the browser into different sections where each section can load different Html documents. Collection of frame is known as Frameset. Creating frames:We use frameset...

2 minutes read.

HTML <style> tag

The section of information that we want to style is contained in html style tag. It includes CSS, which is used to design the text and images in the web page. Syntax: <head> <title>…………....

3 minutes read.