Enable Line Numbering to any HTML Textarea
Lightweight solution without code editor plugins.
While browsing through code snippets online, a handful of code demonstrations are implemented in code playgrounds such as JSFiddle and CodePen:
More often than not due to the nature of code playgrounds where multiple programming languages are implemented onto a single platform, it is more efficient to implement plugins such as CodeMirror which offers multiple features such as autocompletion, custom-language syntax highlights, line numbering etc.
However, when a more simplistic code editor is required instead — where only line numbering is needed, embedding a code editor plugin such as CodeMirror could be an overkill. Fortunately, there is a way to enable line numbering to any HTML Textarea element with just a few lines of Vanilla JavaScript code and CSS styling.