How to add a scrollbar to a table in html

5
9
1.4K followers

Adding a scrollbar to a table is useful, if you want to add additional rows to the table that don't fit into the normal screen or when the table would be cut in half on a mobile device such as a smartphone with a smaller screen.

I run into this issue even though my wordpress theme is responsive.

Here is a simple html code that you can add to the html table code which makes your table scrollable:

Before the table you add into the html text field:

<div style="overflow-x: auto;">

After the table you add:

</div>

This is an example:

This would be the code for the above table with the scrollbar:

<div style="overflow-x: auto;">
<table style="width: 1000px;">
<tbody>
<tr>
<td style="width: 120px;">table row 1</td>
<td style="width: 120px;">table row 2</td>
<td style="width: 120px;">table row 3</td>
<td style="width: 120px;">table row 4</td>
<td style="width: 120px;">table row 5</td>
<td style="width: 120px;">table row 6</td>
</tr>
<tr>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
</tr>
<tr>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
<td style="width: 120px;"></td>
</tr>
</tbody>
</table>
</div>

I hope this may help you.

Sibylle

5
9

Join FREE & Launch Your Business!

Exclusive Bonus - Offer Ends at Midnight Today

00

Hours

:

00

Minutes

:

00

Seconds

2,000 AI Credits Worth $10 USD

Build a Logo + Website That Attracts Customers

400 Credits

Discover Hot Niches with AI Market Research

100 Credits

Create SEO Content That Ranks & Converts

800 Credits

Find Affiliate Offers Up to $500/Sale

10 Credits

Access a Community of 2.9M+ Members

By continuing, you agree to our Terms of Service and Privacy Policy
No credit card required

Recent Comments

9

That is useful tip. thank you.

You are welcome:-)

Great backend advice!

Thanks:-)

1

I will keep this in mind - not ready to try HTML just yet. Thanks for sharing!

Blessings,
Debby

1

My pleasure, hope it helps:-)
Blessings to you as well.
Sibylle

1

Thanks!

That is very helpful Sibylle thank you very much for sharing.

My pleasure, hope it may help at some point.
Sibylle

1

See more comments

Join FREE & Launch Your Business!

Exclusive Bonus - Offer Ends at Midnight Today

00

Hours

:

00

Minutes

:

00

Seconds

2,000 AI Credits Worth $10 USD

Build a Logo + Website That Attracts Customers

400 Credits

Discover Hot Niches with AI Market Research

100 Credits

Create SEO Content That Ranks & Converts

800 Credits

Find Affiliate Offers Up to $500/Sale

10 Credits

Access a Community of 2.9M+ Members

By continuing, you agree to our Terms of Service and Privacy Policy
No credit card required

2.9M+

Members

190+

Countries Served

20+

Years Online

50K+

Success Stories

The world's most successful affiliate marketing training platform. Join 2.9M+ entrepreneurs building their online business with expert training, tools, and support.

© 2005-2025 Wealthy Affiliate
All rights reserved worldwide.

🔒 Trusted by Millions Worldwide

Since 2005, Wealthy Affiliate has been the go-to platform for entrepreneurs looking to build successful online businesses. With industry-leading security, 99.9% uptime, and a proven track record of success, you're in safe hands.