
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to link pages using relative URL in HTML?
In HTML different HTML elements have attributes that contain link to the other resources. The values of these attributes are URL’s, these can be absolute or relative URL’s.
Relative URLs don’t contain full web address. With relative URL we start automatically from the address the browser currently at then we add path components and then extension. Explicitly tells the browser to use the current folder.
Syntax
Following is the syntax to link a page using relative URL.
<a href="relative URL">Link text…</a>
Example
Following is the example program to link a page using relative URL.
Login 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>
SignUp 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>
In the above example we have linked two different pages using relative URL. Relative URLs don’t contain full web address. As we can see in the above example program.
- Related Articles
- How to link pages using absolute URL in HTML?
- How to specify the URL of the page the link goes to in HTML?
- How to use Python Regular expression to extract URL from an HTML link?
- How to convert html pages to pdf using wkhtml2pdf
- How to include CSS in HTML Pages
- How to author fast-loading HTML pages?
- Difference between an Absolute URL and a Relative URL
- How to Parse HTML pages to fetch HTML tables with Python?
- How to link a submit button to another webpage using HTML?
- How to link jQuery in HTML page?
- How to create HTML link that doesnt follow the link?
- Styling html pages in Node.js
- How to test if a URL string is absolute or relative - JavaScript?
- How to create a bookmark link in HTML?
- How to use URL input type in HTML?

Advertisements