HTML Basics

HTML Introduction HTML Basic HTML Comments HTML Tags/Elements HTML Attributes HTML Formatting HTML Block and Inline HTML Charsets HTML Classes HTML Colors HTML Div HTML Headings HTML Id HTML Iframes HTML Images HTML File Paths HTML Tables HTML Layout HTML Lists HTML Links <a> HTML Paragraphs HTML Quotations HTML JavaScript HTML Emojis HTML URL Encode HTML Entities HTML Computercode HTML Symbols HTML Styles

HTML Forms

HTML Forms HTML Form Elements HTML Form Attributes HTML Input Attributes HTML Input Regex HTML Input Form Attributes HTML Input Types

HTML SEO

HTML Head HTML Page Title HTML Responsive HTML Semantics HTML Favicon

HTML Graphics

HTML Canvas HTML SVG

HTML Media

HTML Media HTML Audio HTML Video

HTML Reference

a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption center cite code col colgroup data datalist dd del details dfn dialog dir div dl DOCTYPE dt em embed fieldset figcaption figure font footer form frame frameset h1_-_h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark menu meta meter nav noframes noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select small source span strike strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr

HTML <base> Tag

The HTML <base> tag specifies the base URL for all relative URLs within a document. This means that all relative URLs will be calculated based on the provided base URL.

Usage of the <base> Tag

When using the <base> tag, the URL specified in the href, src, or any other attribute that references a URL in the document will have the base URL prepended to it.

Main Attributes of the <base> Tag

Attribute Description
href Specifies the base URL for all relative URLs in the document.

Example

Consider the following example where the base URL is set to https://www.example.com/. Any relative URLs in the document will be calculated based on this base URL.


<!DOCTYPE html>
<html>
  <head>
    <base href="https://www.example.com/">
  </head>
  <body>
    <a href="page.html">Link to Page</a>
    <img src="image.jpg" alt="Image">
  </body>
</html>

In the example above, the <a> tag and <img> tag reference relative URLs. Since the base URL is set to https://www.example.com/, the URLs will be resolved as follows: