w3-video.com logo

HTML5 Tutorial

Home HTML5 XAMPP .htaccess Firefox Notepad++

Share it



base element, optional

The base element is optional.

Valid Syntax 1
base element present
1
2
3
4
5
6
7
8
9
10
<!doctype html>
<html>
<head>
<title>... <⁄title>
<base>
<⁄head>
<body>

<⁄body>
<⁄html>
Valid Syntax 2
base element absent; optional element
1
2
3
4
5
6
7
8
9
10
<!doctype html>
<html>
<head>
<title>... <⁄title>

<⁄head>
<body>

<⁄body>
<⁄html>

Video demonstration base, optional element

HTML5 base, optional element, Tutorial

min video details
00:02 open html demo file in Notepad++
00:06 base tag is present in head section, but since is optional we can remove it and rework the affected relative urls in page
00:14 for example purpose, we will comment the base line instead of deleting it completely
00:23 the base url points toward a folder called "optional"
00:29 except index.php page all other resources are located inside this folder, like: the css file, images, the linked.php file
00:36 note: in page the path of those resources doesn't indicate the "optional" folder because it is contained in the base url
00:49 but since the base element will be remove soon, we need to add manually this "optional" folder to each resource referred through a relative url
00:59 the base tag also sets a default browsing context: a blank new one
01:04 since we ill remove the base element, this default browsing context will no longer be applied → we will add it manually to each resource in page which could require a browsing context
01:13 reworked finished: this is how the page looks like without the base tag, while maintaining the same display ⁄ functionality
01:14 base tag can now be removed completely from page
base intro base occurrences base browser display base parents all browsing contexts override browsing contexts base resolves only URLs.. base syntaxbase href attributebase target attribute