Home > Web Front-end > HTML Tutorial > How to link pages in HTML using relative URLs?

How to link pages in HTML using relative URLs?

WBOY
Release: 2023-09-14 13:09:02
forward
595 people have browsed it

How to link pages in HTML using relative URLs?

In HTML, different HTML elements have attributes that point to other resources. The value of these properties is a URL, which can be absolute or relative.

Relative URLs do not contain the full URL. With relative URLs, we automatically start at the address where the browser is currently located and then add the path component and extension. Explicitly tell the browser to use the current folder.

grammar

The following is the syntax for linking pages using relative URLs.

<a href="relative URL">Link text…</a>
Copy after login
The Chinese translation of

Example

is:

Example

The following is a sample program that uses relative URLs to link pages.

log in page

<!DOCTYPE html>
<html>
<body>
   <h2>Relative link</h2>
   <h3>Sign In Page</h3>
   <form>
      <label for="fname">Email Address</label><br>
      <input type="text" id="fname" name="fname" ><br>
      <label for="lname">Password</label><br>
      <input type="text" id="lname" name="lname" ><br><br>
      <input type="submit" value="Login"> <a href="Untitled-2.html">Sign Up</a>
   </form>
</body>
</html>
Copy after login

registration page

<!DOCTYPE html>
<html>
<body>
   <h2>Relative link</h2>
   <h3>Sign Up Page</h3>
   <form>
      <label for="fname">Name</label><br>
      <input type="text" id="fname" name="fname" ><br>
      <label for="email">Email</label><br>
      <input type="text" id="email" name="email" ><br>
      <label for="fname">Password</label><br>
      <input type="text" id="fname" name="fname" ><br>
      <label for="lname"> Re-enter Password</label><br>
      <input type="text" id="lname" name="lname" ><br><br>
      <input type="submit" value="Submit"> <a href="Untitled-1.html">Login</a>
   </form>
</body>
</html>
Copy after login

In the above example, we linked two different pages using relative URLs. Relative URLs do not contain the full URL. As we can see in the sample program above.

The above is the detailed content of How to link pages in HTML using relative URLs?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template