diff --git a/OpenDreamClient/Interface/Html/HtmlParser.cs b/OpenDreamClient/Interface/Html/HtmlParser.cs
index ef434e83c2..6641c1294f 100644
--- a/OpenDreamClient/Interface/Html/HtmlParser.cs
+++ b/OpenDreamClient/Interface/Html/HtmlParser.cs
@@ -84,7 +84,8 @@ void PushCurrentText() {
} else {
tags.Push(tagType);
- appendTo.PushTag(new MarkupNode(tagType, null, ParseAttributes(attributes)), selfClosing: attributes[^1] == "/");
+ bool isSelfClosing = IsSelfClosing(tagType, attributes);
+ appendTo.PushTag(new MarkupNode(tagType, null, ParseAttributes(attributes)), selfClosing: isSelfClosing);
}
break;
@@ -139,6 +140,39 @@ void PushCurrentText() {
appendTo.Pop();
}
+ /**
+ *
+ * Returns if a tag is written in old self-closing form, or if the tag
+ * represents a void element, which must have no children
+ *
+ */
+ private static bool IsSelfClosing(string tagType, string[] attributes) {
+ if (attributes[^1] == "/") {
+ return true;
+ }
+
+ switch (tagType) {
+ case "area":
+ case "base":
+ case "br":
+ case "col":
+ case "embed":
+ case "hr":
+ case "img":
+ case "input":
+ case "link":
+ case "meta":
+ case "param":
+ case "source":
+ case "track":
+ case "wbr":
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
private static Dictionary ParseAttributes(string[] attributes) {
Dictionary parsedAttributes = new();