< Up a Level

code-input in HTML5 Forms

Contributors: 2025 Oliver Geer

code-input elements support HTML5 forms. Form-related HTML5 attributes and events on them will be passed to a textarea element inside them when they are registered, and whenever the attributes or events are later changed.

This is a good time to make use of the fallback textarea which is used when JavaScript is disabled; the following code will send data to the HTML5 form correctly whether or not JavaScript is enabled:

<form>
    <code-input><textarea code-input-fallback name="code"></textarea></code-input>
    <input type="submit"/>
</form>