<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc" -->

---
title: These two features make styling textareas easier | daily.dev
description: Two CSS techniques simplify styling textareas: using the lh (line-height) unit combined with min-height or min-block-size lets a textarea's size scale...
canonical: https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: These two features make styling textareas easier | daily.dev
og:description: Two CSS techniques simplify styling textareas: using the lh (line-height) unit combined with min-height or min-block-size lets a textarea's size scale...
og:url: https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc
og:image: https://api.daily.dev/og/posts/txTV2sihc.png
og:image:alt: These two features make styling textareas easier
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# These two features make styling textareas easier

**[Kevin Powell](https://daily.dev/sources/kevinpowell)** · 1 min read · 6 upvotes · 1 comments

## Summary

Two CSS techniques simplify styling textareas: using the lh (line-height) unit combined with min-height or min-block-size lets a textarea's size scale correctly with font-size changes, avoiding magic-number hacks. The field-sizing: content CSS property lets a textarea automatically grow as more text is typed, replacing JavaScript-based auto-resize logic with a single line of CSS, useful for chat apps and similar expanding inputs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=Z1d428X-6rU>

## Questions this post answers

### How do I make a textarea automatically grow in height as the user types more text using only CSS?

Use the CSS property field-sizing: content on the textarea. This makes the textarea automatically expand with each new line of text instead of showing a scrollbar, which is especially useful for chat apps or other inputs that need to expand. This previously required a decent amount of JavaScript but now works with a single line of CSS.

_daily.dev surfaces practical CSS techniques like this for developers replacing JS hacks with native features._

### How can I size a textarea to a fixed number of lines that stays correct even if the font size changes?

Use the CSS lh (line-height) unit instead of hardcoded pixel values, since lh is relative to the element's line height. Applying it to min-height or, better, the logical property min-block-size keeps a textarea sized to a fixed number of lines regardless of font-size changes, avoiding manual recalculation or magic numbers.

_Developers tuning form styling can track CSS unit tricks like this via daily.dev to skip magic-number guesswork._

## Community discussion

Top comments from developers on daily.dev.

**@user45613** · 2 upvotes

> !important

## Similar posts on daily.dev

- [Auto-growing textareas with field-sizing: content](https://daily.dev/posts/auto-growing-textareas-with-field-sizing-content-51kawyp3w) · RUBYLAND · 1 upvotes · 0 comments
- [Understanding CSS Text-Box: Simplifying Padding Solutions](https://daily.dev/posts/understanding-css-text-box-simplifying-padding-solutions-jegps7bip) · Frontend Masters · 7 upvotes · 0 comments
- [Transitioning Field Sizing Content With CSS · October 3, 2026](https://daily.dev/posts/transitioning-field-sizing-content-with-css-october-3-2026-gbbw5edae) · Adam Argyle · 3 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css), [#ui-design](https://daily.dev/tags/ui-design)

[View this post on daily.dev](https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"These two features make styling textareas easier","url":"https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc"},"datePublished":"2026-09-24T13:20:55.298Z","dateModified":"2026-09-24T13:21:12.265Z","description":"Two CSS techniques simplify styling textareas: using the lh (line-height) unit combined with min-height or min-block-size lets a textarea's size scale...","image":"https://i.ytimg.com/vi/Z1d428X-6rU/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/Z1d428X-6rU/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Kevin Powell","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Kevin Powell","logo":"https://media.daily.dev/image/upload/s--XK5Rf0kM--/f_auto/v1717745137/logos/kevinpowell","url":"https://daily.dev/sources/kevinpowell"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"css,ui-design","timeRequired":"PT1M","video":{"@type":"VideoObject","name":"These two features make styling textareas easier","description":"Two CSS techniques simplify styling textareas: using the lh (line-height) unit combined with min-height or min-block-size lets a textarea's size scale...","thumbnailUrl":"https://i.ytimg.com/vi/Z1d428X-6rU/sddefault.jpg","uploadDate":"2026-09-24T13:20:55.298Z","duration":"PT1M","url":"https://api.daily.dev/r/txTV2sihc","embedUrl":"https://www.youtube.com/embed/Z1d428X-6rU"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Kevin Powell","item":"https://daily.dev/sources/kevinpowell"},{"@type":"ListItem","position":3,"name":"These two features make styling textareas easier"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc","comment":[{"@type":"Comment","text":"!important","datePublished":"2026-09-24T13:37:35.595Z","url":"https://daily.dev/posts/txTV2sihc#c-tuZ9MmoTi","author":{"@type":"Person","name":"Veselin Ivanov","url":"https://daily.dev/user45613","image":"https://media.daily.dev/image/upload/s--nc0o8dM8--/f_auto/v1782457323/avatars/avatar_JYf2mTyl8QY4B2HJp3soD?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/these-two-features-make-styling-textareas-easier-txtv2sihc#faq","mainEntity":[{"@type":"Question","name":"How do I make a textarea automatically grow in height as the user types more text using only CSS?","acceptedAnswer":{"@type":"Answer","text":"Use the CSS property field-sizing: content on the textarea. This makes the textarea automatically expand with each new line of text instead of showing a scrollbar, which is especially useful for chat apps or other inputs that need to expand. This previously required a decent amount of JavaScript but now works with a single line of CSS. daily.dev surfaces practical CSS techniques like this for developers replacing JS hacks with native features."}},{"@type":"Question","name":"How can I size a textarea to a fixed number of lines that stays correct even if the font size changes?","acceptedAnswer":{"@type":"Answer","text":"Use the CSS lh (line-height) unit instead of hardcoded pixel values, since lh is relative to the element's line height. Applying it to min-height or, better, the logical property min-block-size keeps a textarea sized to a fixed number of lines regardless of font-size changes, avoiding manual recalculation or magic numbers. Developers tuning form styling can track CSS unit tricks like this via daily.dev to skip magic-number guesswork."}}]}
```

