<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/new-alternatives-to-innerhtml-kstkek6je" -->

---
title: New alternatives to innerHTML | daily.dev
description: New alternatives to innerHTML have been implemented in browsers. The setHTML function is a safe method that does not execute script, while setHTMLUnsafe is an...
canonical: https://daily.dev/posts/new-alternatives-to-innerhtml-kstkek6je
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: New alternatives to innerHTML | daily.dev
og:description: New alternatives to innerHTML have been implemented in browsers. The setHTML function is a safe method that does not execute script, while setHTMLUnsafe is an...
og:url: https://daily.dev/posts/new-alternatives-to-innerhtml-kstkek6je
og:image: https://api.daily.dev/og/posts/KstkEK6Je.png
og:image:alt: New alternatives to innerHTML
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# New alternatives to innerHTML

**[Community Picks](https://daily.dev/sources/community)** · 3 min read · 177 upvotes · 3 comments

## Summary

New alternatives to innerHTML have been implemented in browsers. The setHTML function is a safe method that does not execute script, while setHTMLUnsafe is an unsafe method that poses a risk of XSS attacks. The Sanitizer API helps put the naming of setHTMLUnsafe in context. The setHTMLUnsafe function is useful for declarative shadow DOM. The getHTML function allows users to retrieve HTML content, with the ability to serialize shadow DOM.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://fullystacked.net/innerhtml-alternatives/>

## Community discussion

Top comments from developers on daily.dev.

**@idoshamun** · 5 upvotes

> Once `setHtml` will land it will be so much easier and faster to send html over the wire with having to care about sanitization

**@apperside** · 4 upvotes

> Really good news, but we really had to wait for 2024 for this method?? 🤷

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#html](https://daily.dev/tags/html), [#dom](https://daily.dev/tags/dom)

[View this post on daily.dev](https://daily.dev/posts/new-alternatives-to-innerhtml-kstkek6je)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"New alternatives to innerHTML","url":"https://daily.dev/posts/new-alternatives-to-innerhtml-kstkek6je","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/new-alternatives-to-innerhtml-kstkek6je"},"datePublished":"2024-05-08T20:37:54.629Z","dateModified":"2024-05-09T08:22:04.995Z","description":"New alternatives to innerHTML have been implemented in browsers. The setHTML function is a safe method that does not execute script, while setHTMLUnsafe is an...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/e468f1c8f3fb23a39a6f5eb44ac67a88?_a=AQAEuiZ","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/e468f1c8f3fb23a39a6f5eb44ac67a88?_a=AQAEuiZ","isAccessibleForFree":true,"articleSection":"Community Picks","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Community Picks","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1655817725/logos/community","url":"https://daily.dev/sources/community"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/new-alternatives-to-innerhtml-kstkek6je","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":177},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"javascript,html,dom","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Community Picks","item":"https://daily.dev/sources/community"},{"@type":"ListItem","position":3,"name":"New alternatives to innerHTML"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/new-alternatives-to-innerhtml-kstkek6je","comment":[{"@type":"Comment","text":"Once setHtml will land it will be so much easier and faster to send html over the wire with having to care about sanitization","datePublished":"2024-05-11T17:09:44.718Z","url":"https://daily.dev/posts/KstkEK6Je#c-LNnhApKio","author":{"@type":"Person","name":"Ido Shamun","url":"https://daily.dev/idoshamun","image":"https://media.daily.dev/image/upload/s---xy_OAwk--/f_auto,q_auto/v1703781380/avatars/avatar_28849d86070e4c099c877ab6837c61f0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5}},{"@type":"Comment","text":"Really good news, but we really had to wait for 2024 for this method?? 🤷","datePublished":"2024-05-16T11:59:05.672Z","url":"https://daily.dev/posts/KstkEK6Je#c-9n47193ti","author":{"@type":"Person","name":"Apperside","url":"https://daily.dev/apperside","image":"https://avatars.githubusercontent.com/u/5955338?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4}}]}
```

