


Explanation on the usage of HTML a tag href attribute to specify relative path and absolute path
href is one of the most commonly used important attributes for linking front-end files. Here we will take a look at the usage of the HTML a tag href attribute to specify relative paths and absolute paths. Friends who need it can refer to
In actual web development, inserting pictures, including CSS files, etc. all require paths. If the file path is added incorrectly, the reference will be invalid (the linked file cannot be browsed, or the inserted picture cannot be displayed, etc.). Many beginners are confused. Below I will introduce relative paths and absolute paths in detail.
HTML relative path
refers to the path relationship with other files (or folders) caused by the path where this file is located.
For example:
The absolute path of file 1.htm is: d:/www/html/1.htm
The absolute path of file 2.htm is: d:/www/html/2.htm
Then: the path of 1.htm relative to 2.htm is: 1.htm
How to use relative links:
If the link is to the same directory, just Enter the name of the document to be linked, for example:
XML/HTML CodeCopy the content to the clipboard
<a href =”1 htm”>网页链接 </a> <img src=”bg.jpg” / alt="Explanation on the usage of HTML a tag href attribute to specify relative path and absolute path" >
If linking to the next level directory , you need to enter the directory name first, then add "/", and then enter the file name, for example:
XML/HTML CodeCopy the content to the clipboard
<a href =”html/ next.htm”> <img src=”images/bg.jpg” / alt="Explanation on the usage of HTML a tag href attribute to specify relative path and absolute path" >
If you connect to the upper-level directory, you need to enter "../" first, and then enter the directory name and file name, for example:
XML/HTML Code Copy content to clipboard
<a href = “../ www/index.htm”>
Example summary
There are now 4 html files, namely aaa.html bbb.html ccc The path of .html index.html
aaa.html is: D:/www/adminwang/html/aaa.html
bbb.html is: D:/www/adminwang/ bbb.html
The path of ccc.html is: D:/www/ ccc.html
The path of index.html is D:/www/ index.html
1. Link files in the same directory
For example, the code for the ccc.html file link index.html is as follows:
XML/HTML CodeCopy the content to the clipboard
<a href="index.html">链接index网页</a>
2. Link to the file in the previous directory
For example, the code for linking bbb.html to ccc.html is as follows:
XML/HTML Code Copy the content to the clipboard
<a href="../ccc.html">链接ccc网页</a>
3. Link to the file in the upper 2-level directory
For example, aaa.html link The code of ccc.html is as follows:
XML/HTML CodeCopy the content to the clipboard
<a href=”../../ccc.html”>链接ccc网页</a>
4. Link to lower-level directories File
For example, the code of ccc.html link to bbb.html is as follows:
XML/HTML CodeCopy the content to the clipboard
<a href="adminwang/bbb.html">链接bbb网页</a>
5. Link files in the lower 2-level directory
For example, the code for linking ccc.html to aaa.html is as follows:
XML/HTML CodeCopy content to clipboard
<a href="adminwang/html/aaa.html">链接aaa网页</a>
HTML Absolute Path
Provide the full path to the file, including the applicable protocol or drive letter. That is, the real full path of the file or directory on your home page on the hard disk. For example:
http://www.adminwang.com/index.htm
d:/ www /html/images/bg.jpg
There is nothing to say about the absolute path, but the relative path is mastered , the absolute path is very simple.
For more explanations on how to use the href attribute of the HTML a tag to specify relative paths and absolute paths, please pay attention to the PHP Chinese website!

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software