diff --git a/README.md b/README.md
index 4ecc0d2..0f53b3d 100644
--- a/README.md
+++ b/README.md
@@ -148,7 +148,24 @@ In this example, if `isAdmin` is `true`, the `Admin Panel` link is rendered. Oth
- **Script-supporting Elements**: `Script`, `Noscript`
- **Inline Semantic**: `A`, `Strong`, `Em`, `Code`, `I`
-### Additional Utility: HTML Comments
+### Raw HTML Insertion
+
+The `Raw` function allows for the direct inclusion of raw HTML content within your document structure. This function can be used to insert HTML strings, which will be rendered as part of the final HTML output.
+
+```go
+rawHTML := `
Custom HTML content
`
+content := elem.Div(nil,
+ elem.H1(nil, elem.Text("Welcome to Elem-Go")),
+ elem.Raw(rawHTML), // Inserting the raw HTML
+ elem.P(nil, elem.Text("More content here...")),
+)
+
+htmlOutput := content.Render()
+// Output:
Welcome to Elem-Go
Custom HTML content
More content here...
+```
+> **NOTE**: If you are passing HTML from an untrusted source, make sure to sanitize it to prevent potential security risks such as Cross-Site Scripting (XSS) attacks.
+
+### HTML Comments
Apart from standard elements, `elem-go` also allows you to insert HTML comments using the `Comment` function:
diff --git a/elem.go b/elem.go
index 2931bbc..edd8e14 100644
--- a/elem.go
+++ b/elem.go
@@ -68,6 +68,16 @@ func (t TextNode) Render() string {
return string(t)
}
+type RawNode string
+
+func (r RawNode) RenderTo(builder *strings.Builder) {
+ builder.WriteString(string(r))
+}
+
+func (r RawNode) Render() string {
+ return string(r)
+}
+
type CommentNode string
func (c CommentNode) RenderTo(builder *strings.Builder) {
diff --git a/elements.go b/elements.go
index be0e2e1..b4db73a 100644
--- a/elements.go
+++ b/elements.go
@@ -396,3 +396,10 @@ func Video(attrs attrs.Props, children ...Node) *Element {
func Source(attrs attrs.Props, children ...Node) *Element {
return NewElement("source", attrs, children...)
}
+
+// ========== Other ==========
+
+// Raw takes html content and returns a RawNode.
+func Raw(html string) RawNode {
+ return RawNode(html)
+}
diff --git a/elements_test.go b/elements_test.go
index 1cd26cb..1ea166c 100644
--- a/elements_test.go
+++ b/elements_test.go
@@ -474,6 +474,7 @@ func TestTable(t *testing.T) {
}
// ========== Embedded Content ==========
+
func TestEmbedLink(t *testing.T) {
expected := ``
el := IFrame(attrs.Props{attrs.Src: "https://www.youtube.com/embed/446E-r0rXHI"})
@@ -505,3 +506,13 @@ func TestVideoWithSourceElementsAndFallbackText(t *testing.T) {
)
assert.Equal(t, expected, el.Render())
}
+
+// ========== Other ==========
+
+func TestRaw(t *testing.T) {
+ rawHTML := `