How to create a DIV with only vertical scrollbars for long paragraphs with HTML and CSS?

Spread the love

Sometimes, we want to create a DIV with only vertical scrollbars for long paragraphs with HTML and CSS.

In this article, we’ll look at how to create a DIV with only vertical scrollbars for long paragraphs with HTML and CSS.

How to create a DIV with only vertical scrollbars for long paragraphs with HTML and CSS?

To create a DIV with only vertical scrollbars for long paragraphs with HTML and CSS, we set the overflow property.

For instance, we write

<div style="width: 100px; height: 100px; overflow: auto">
  text text text text text text text text text text text text text text text
  text text text text text text text text text text text text text text text
  text text text text text text text text text text text text text text text
  text text text text text text text text text text text text text text text
  text text text text text text text text text text text text
</div>

to show the scroll bar when the text overflows the div with overflow: auto.

Conclusion

To create a DIV with only vertical scrollbars for long paragraphs with HTML and CSS, we set the overflow property.

Leave a Reply

Your email address will not be published.