12

So I have a div tag to sort of draw boxes around various sections, and of course make actual sections.

In one of the sections, there is more text than can be held in the div tag, so I want to for the text within the div tag to have a scroll bar to make it so the text doesn't overflow outside of the box.

How would I do that?

2 Answers 2

29

Use the following:

div {
    overflow: scroll;
}

If you want them to scroll only in one direction, you can use the overflow-x and overflow-y properties.

Sign up to request clarification or add additional context in comments.

Comments

23

Add width and height CSS properties to the div, as well as overflow:auto

If you add overflow:scroll, the scroll bars will be always visible.

If you want to have only horizontal scroll, add white-space:nowrap to the element inside of the div.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.