Download our Free HTML Cheat Sheet - Quick Reference for Beginners

Scrolling div code generator

Enable scrolling for your divs to display content which may be too large for an area
Your site might have some content that may be too large for an area. This information could be dynamic, extracted from an external source, and might be different in size. Instead of your div changing size due to varying amounts of information within it, you can add a scrollbar which keeps the area for the information the same size all the time, but adds a scrollbar to the div if the content exceeds the size you'd like it to be.

Div options

Div ID:
Not seen, must be unique on the page where it is placed
Width:
Height:
Background color:
Border style:
Padding:
Margin:
Content align:
Div contents:
This can be any HTML content

Code options

Choose how you want the code created
CSS layout:
Unsure? Leave it inline

Frequently asked questions

What's the difference between this and just setting overflow:auto myself?

Nothing under the hood - that's exactly what this generates. The generator just saves you writing and testing the width, height, border and padding CSS by hand, and lets you preview it before copying the code.

When should I use "auto" vs always showing a scrollbar?

This generator uses overflow:auto, which only shows a scrollbar when the content actually exceeds the box - the cleanest choice for most cases. Use overflow:scroll instead (edit the generated CSS) if you specifically want the scrollbar always visible, even when content fits, for a consistent layout width.

Can I put images or other HTML inside the scrolling area?

Yes - whatever you paste into the div contents box is placed inside the div as-is, so images, links, lists and other HTML all work normally.

Will this work well on mobile?

Yes, touch scrolling inside a fixed-size div works on all modern mobile browsers. Just make sure the width you set isn't wider than small screens - use a percentage width instead of a fixed pixel width if you want it to adapt.