{"id":2528,"date":"2011-09-01T02:46:20","date_gmt":"2011-09-01T06:46:20","guid":{"rendered":"http:\/\/www.ericfeminella.com\/blog\/?p=2528"},"modified":"2016-03-31T11:30:53","modified_gmt":"2016-03-31T15:30:53","slug":"html5-elements-the-base-tag","status":"publish","type":"post","link":"https:\/\/www.ericfeminella.com\/blog\/2011\/09\/01\/html5-elements-the-base-tag\/","title":{"rendered":"HTML5 Elements: The &lt;base&gt; Tag"},"content":{"rendered":"<p>The <a href=\"http:\/\/dev.w3.org\/html5\/spec\/Overview.html\" target=\"_blank\">HTML5 Specification<\/a> introduces many new semantic elements, as well as specifications for existing elements; one of which is the <code><a href=\"http:\/\/dev.w3.org\/html5\/spec\/Overview.html#the-base-element\" target=\"_blank\">&lt;base&gt;<\/a><\/code> Tag, which allows for specifying a root URL from which all linkable elements in a document (hyperlinks, images etc.) are based, as well as a default <code>target<\/code> for all linkable elements. <\/p>\n<h3>Overview<\/h3>\n<ul>\n<li>The <code>&lt;base&gt;<\/code> Tag provides two attributes; <code><a href=\"http:\/\/www.w3schools.com\/html5\/att_a_href.asp\" target=\"_blank\">href<\/a><\/code> (Hyper-text Reference) and <code><a href=\"http:\/\/www.w3schools.com\/html5\/att_a_target.asp\" target=\"_blank\">target<\/a><\/code>, respectively, which have the same semantic meaning as that of a <code><a href=\"http:\/\/www.w3schools.com\/html5\/tag_a.asp\" target=\"_blank\">hyperlink<\/a><\/code>.\n<\/li>\n<li>Only a single <code>&lt;base&gt;<\/code> Tag is to be defined per page and, must be defined before any elements which except a <code><a href=\"http:\/\/dev.w3.org\/html5\/spec\/Overview.html#url\" target=\"_blank\">URL<\/a><\/code> are defined (other than the <code><a href=\"http:\/\/dev.w3.org\/html5\/spec\/Overview.html#the-html-element\" target=\"_blank\">html<\/a><\/code> element).\n<\/li>\n<\/ul>\n<p>Note: <i>While the <code>&lt;base&gt;<\/code> Tag is not new to HTML5, the changes to the <code><a href=\"http:\/\/www.w3schools.com\/html5\/tag_a.asp\" target=\"_blank\">a<\/a><\/code> Tag implies a difference (albeit, marginal) as, <code><a href=\"http:\/\/www.w3schools.com\/html5\/tag_a.asp\" target=\"_blank\">a<\/a><\/code> Tags are always hyperlinks, or placeholders for hyperlinks.<\/i><\/p>\n<h3>Example<\/h3>\n<p>Like all HTML markup, usage of the <code>&lt;base&gt;<\/code> Tag is easy and straightforward: Simply add a single <code>&lt;base&gt;<\/code> Tag in the <code>&lt;head&gt;<\/code> element of the document and define either a base URL and \/ or default target attribute. <\/p>\n<h4>Defining a default base URL and target:<\/h4>\n<pre lang=\"html\">\r\n<!DOCTYPE html>\r\n<html>\r\n    <head>\r\n        <base href=\"http:\/\/somedomain\/app\" target=\"_blank\" \/>\r\n    <\/head>\r\n    <body>\r\n        <nav>\r\n            <a href=\"index.php\">Home<\/a>\r\n            <a href=\"aboutus.php\">About Us<\/a>\r\n            <a href=\"contactus.php\">Contact Us<\/a>\r\n        <\/nav>\r\n    <\/body>\r\n<\/html>\r\n<\/pre>\n<p>\nThe above links will all default to a blank <code>target<\/code> (new page), with each link&#8217;s base URL defaulting to &#8220;http:\/\/somedomain\/app&#8221;. Individual links can override the base URL as well as the default <code>target<\/code>.\n<\/p>\n<h3>Support<\/h3>\n<p>The <code>&lt;base&gt;<\/code> Tag is currently supported by all major browsers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The HTML5 Specification introduces many new semantic elements, as well as specifications for existing elements; one of which is the &lt;base&gt; Tag, which allows for specifying a root URL from which all linkable elements in a document (hyperlinks, images etc.) are based, as well as a default target for all linkable elements. Overview The &lt;base&gt; Tag provides two attributes; href&#8230; <a class=\"read-more\" href=\"https:\/\/www.ericfeminella.com\/blog\/2011\/09\/01\/html5-elements-the-base-tag\/\">Continue Reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[59],"tags":[65,127,125,126,64,131,82],"class_list":["post-2528","post","type-post","status-publish","format-standard","hentry","category-html5","tag-html5-2","tag-html5-attributes-2","tag-html5-elements-2","tag-html5-semantics-2","tag-mobile-web","tag-touchscreen","tag-web"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts\/2528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/comments?post=2528"}],"version-history":[{"count":0,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts\/2528\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/media?parent=2528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/categories?post=2528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/tags?post=2528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}