Home Web Front-end HTML Tutorial How to make HTML link code? How to create an HTML image link?

How to make HTML link code? How to create an HTML image link?

Aug 14, 2018 pm 01:13 PM

How to create HTML link code? How to create an HTML image link? This article will introduce you to the text link code and image link code in detail.

First of all, we need to understand what the link code of HTML is:

The link code of HTML is the code in HTML that turns some text into a hyperlink.

HTML uses a hyperlink to connect to another document on the web.

Links can be found in almost all web pages. Click a link to jump from one page to another.

How to make HTML link code:

HTML hyperlink (link)

Hyperlink can be a word, a word, or a group It can also be a word or an image. You can click on these contents to jump to a new document or a certain part of the current document.

When you move the mouse pointer over a link on the web page, the arrow will change into a small hand.

We create links in HTML by using the tag.

There are two ways to use the tag:

By using the href attribute - creating a link to another document

By using the name attribute - creating a link within the document The bookmark

HTML link syntax

The HTML code for the link is very simple. It looks like this:

<a href="url">Link text</a>
Copy after login

The href attribute specifies the target of the link.

The text between the opening tag and the closing tag is displayed as a hyperlink.

For example:

<a href="http://www.PHP.cn/">Visit PHP中文网</a>
Copy after login

The above line of code displays as: Visit PHP Chinese website

Clicking this hyperlink will take the user to the homepage of the PHP Chinese website.

Creation of HTML image links:

"Link text" does not have to be text. Images or other HTML elements can become links.

For example:

You can turn an element into a link by nesting it into an a element.

Nest your image into an a element. For example:

<a href="#"><img src="/images/relaxing-cat.jpg"></a>
Copy after login

"images/relaxing-cat.jpg" This is the name of the picture.

Use a tag to implement

<a href="链接的地址"><img src="图片的URL" width="图片的宽度" height="图片的高度" border="边框"></a>
Copy after login


Definition and usage
tag defines a hyperlink, used to link from one page to another page. The most important attribute of the
element is the href attribute, which indicates the target of the link.

HTML Links - target attribute

Using the Target attribute, you can define where the linked document is displayed.

The following line will open the document in a new window:

HTML link - name attribute

name attribute specifies the name of the anchor (anchor) .

You can use the name attribute to create bookmarks in HTML pages.

The bookmark is not displayed in any special way and is invisible to the reader.

When using named anchors, we can create links that jump directly to the named anchor (such as a section on the page), so users don’t have to scroll the page to find what they need. information.

Syntax for naming anchors:

Tip: The name of the anchor can be anything you like.

Tip: You can use the id attribute instead of the name attribute. Named anchors are also valid.

Here are examples:

First, we name the anchor in the HTML document (create a bookmark):

Basic Notes - Helpful Tips

We then create a link to that anchor in the same document:

Helpful Tips

You can also create links to this anchor in other pages:

Useful Tips

In the above code, we add the # symbol and the anchor name to the end of the URL to link directly to the tips Name the anchor.

Okay, the above is about the production of link codes and image links in HTML.

[Related recommendations]

The basic elements of html, allowing you to learn HTML from scratch

What is an HTML file? A preliminary understanding of HTML files


The above is the detailed content of How to make HTML link code? How to create an HTML image link?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles