diff --git a/src/browser/Page.zig b/src/browser/Page.zig
index 8878d9aa..6f39ec08 100644
--- a/src/browser/Page.zig
+++ b/src/browser/Page.zig
@@ -1430,6 +1430,24 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
attribute_iterator,
.{ ._proto = undefined },
),
+ asUint("base") => {
+ const n = try self.createHtmlElementT(
+ Element.Html.Generic,
+ namespace,
+ attribute_iterator,
+ .{ ._proto = undefined, ._tag_name = String.init(undefined, "base", .{}) catch unreachable, ._tag = .base },
+ );
+
+ // If page's base url is not already set, fill it with the base
+ // tag.
+ if (self.base_url == null) {
+ if (n.as(Element).getAttributeSafe("href")) |href| {
+ self.base_url = try URL.resolve(self.arena, self.url, href, .{});
+ }
+ }
+
+ return n;
+ },
else => {},
},
5 => switch (@as(u40, @bitCast(name[0..5].*))) {
diff --git a/src/browser/tests/node/base_uri.html b/src/browser/tests/node/base_uri.html
new file mode 100644
index 00000000..122d7d13
--- /dev/null
+++ b/src/browser/tests/node/base_uri.html
@@ -0,0 +1,14 @@
+
+
+
+
+foo
+
+
+
diff --git a/src/browser/webapi/Element.zig b/src/browser/webapi/Element.zig
index fe5effac..a3a542a8 100644
--- a/src/browser/webapi/Element.zig
+++ b/src/browser/webapi/Element.zig
@@ -1178,6 +1178,7 @@ pub const Tag = enum {
body,
br,
button,
+ base,
canvas,
circle,
custom,