HTML Allowlist for Lightning Web Security
LWS doesn’t sanitize input text. It only filters HTML strings that components inserted into the DOM. Your code must validate or sanitize any user input.
Here’s a list of allowed HTML elements that are retained in the DOM after sanitization. Lightning Web Security (LWS) removes HTML elements that aren’t in this list.
a, abbr, acronym, address, area, article, aside, audiob, bdi, bdo, big, blockquote, body, br, buttoncaption, canvas, center, cite, code, col, colgroup, commanddatalist, dd, del, details, dfn, dir, div, dl, dtemfieldset, figure, figcaption, footer, formh1, h2, h3, h4, h5, h6, head, header, hgroup, hri, iframe, img, input, inskeygen, kbdlabel, legend, limap, mark, menu, meternavol, optgroup, option, outputp, pre, progressqrp, rt, rubys, samp, section, select, small, source, span, strike, strong, style, sub, summary, suptable, tbody, td, textarea, tfoot, th, thead, time, tr, track, ttu, ulvar, videowbr
For example, this code contains a <script> tag, which isn’t allowed.
After sanitization, it becomes: