< Up a Level

Styling code-input elements with CSS

Contributors: 2025 Oliver Geer

code-input elements can be styled like textarea elements in most cases; however, there are some exceptions:

Please do not use className in JavaScript referring to code-input elements, because the code-input library needs to add its own classes to code-input elements for easier progressive enhancement. You can, however, use classList and style as much as you want - it will make your code cleaner anyway.

Methods of resizing

code-input elements default to having a fixed height and filling the width of their container while the code inside scrolls, and you can set the ordinary CSS properties (for example height and width) to change this size. You can also make the size more flexible using CSS:

A syntax-highlighted code input element with diagonal lines in the corner, which can be dragged to resize the element.