Computer >> Computer tutorials >  >> Programming >> Javascript

How to add a base URL for all the links in a page in HTML?


To add a base URL, use the <base> tag in HTML. For example, you can set the base URL once at the top of your page in the header section, then all subsequent relative links will use that URL as a starting point.

Example

You can try to run the following code to learn how to add a base URL for all the links in a page in HTML −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML base Tag</title>
      <base href = "https://www.qries.com" />
   </head>
   <body>
      Qries.com <img src = "/images/banner_logo.png" />
   </body>
</html>