Auto-growing Textarea in New Lines

Written by @kerixa 27 February 2021

When an unknown number of lines is needed in a textarea, utilization from an auto-growing or auto -expanding textarea is essential. As visitors write and go to new lines, the textarea size increases and new lines are added to it. The following code example shows how to make such textareas with variable height.

Code Snippet:

                                                <!-- this script is provided by coded by: Kerixa Inc. -->
.input-sizer {
    display: inline-grid;
    vertical-align: top;
    align-items: center;
    position: relative;
    border-bottom: solid 1px #ced4da;

    .input-sizer.stacked {
        width: 100%;
        align-items: stretch;

        .input-sizer.stacked input,
        .input-sizer.stacked textarea {
            grid-area: 2/1;

    .input-sizer > span {
        padding: 0.25em;
        font-size: 1rem;

    .input-sizer input,
    .input-sizer textarea {
        width: auto;
        min-width: 1em;
        grid-area: 1/2;
        font: inherit;
        padding: 0.25em;
        margin: 0;
        resize: none;
        background: none;
        appearance: none;
        border: none;

    .input-sizer::after {
        content: attr(data-value) " ";
        visibility: hidden;
        white-space: pre-wrap;

    .input-sizer:focus-within {
        outline: none;
        border-bottom: solid 1px blue;

        .input-sizer:focus-within > span {
            color: blue;

        .input-sizer:focus-within textarea:focus,
        .input-sizer:focus-within input:focus {
            outline: none;
<link rel='stylesheet' href=''>
<script src=''></script>

<form action="">
	<div class="form-group col-sm-12">
		<label for="" class="input-sizer stacked">
			<span>Your Message </span>
			<textarea oninput="this.parentNode.dataset.value = this.value" rows="1" placeholder=""></textarea>
<font face="Tahoma"><a target="_blank" href=""><span style="font-size: 8pt; text-decoration: none">HTML Free Code</span></a></font>
<a target='_blank' href='' style='font-size: 8pt; text-decoration: none'>Html Free Codes</a>                                                


About @kerixa

I am Krishna Eydat. I studied Software Engineering at University of Waterloo in Canada. I lead a few tech companies. I am passionate about the way we are connected. I would like to be part of something big or be the big deal!



Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

Online Users: 12
Recent Members: Prashanthcs11, Designer Diva, Jirgensons E, vamsi, wapmohin
advertisement 2