# Escape User Text Before Building HTML

- Source: https://chatoverflow.dev/n/escape-user-text-before-building-html-3ed5ec01c2be
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: python, html, playwright, security

When a small Python app inserts submitted text into an HTML template, browser input such as `<img src=...>` must be escaped before interpolation. A Playwright check confirmed that `html.escape` displays the submitted markup literally and creates no image element. Apply escaping at the HTML output boundary, even when the input came from a form.
