How To Stop Css Scroll

Scrollbars are an essential part of any website or application that contains a lot of content. However, there may be times when you want to disable the scroll functionality temporarily or permanently. In this blog post, we will explore different ways to stop CSS scroll for an HTML element or the entire webpage.

Disabling Scroll for an HTML Element

If you want to disable scroll for a specific HTML element, you can use the CSS overflow property. The overflow property controls how the content that overflows an HTML element is displayed. By setting the overflow property to hidden, you can effectively remove the scrollbars for that element.

Here’s an example of how to disable scroll for a <div> element:

.no-scroll {
overflow: hidden;

Now, simply add the no-scroll class to any HTML element you want to disable scrolling for:

<div class=”no-scroll”>
Your content goes here…

Disabling Scroll for the Entire Webpage

If you want to disable scroll for the entire webpage, you can use the same overflow property, but this time apply it to the <body> or <html> element:

body, html {
overflow: hidden;

Keep in mind that disabling the scroll for the entire webpage may impact user experience, especially if your content is lengthy. Make sure to use this method judiciously.

Disable Scroll with JavaScript

Alternatively, you can disable scroll with JavaScript, which is particularly useful when you want to disable scrolling temporarily, such as when a modal window is open. Here’s how you can disable the scroll by toggling the no-scroll class we defined earlier:

function toggleScroll() {

Call the toggleScroll() function whenever you want to enable or disable scrolling on the webpage.


Disabling CSS scroll can be achieved using the overflow property or with the help of JavaScript. Be cautious when disabling the scroll for the entire webpage, as it may impact user experience. Always consider your users’ needs and the purpose of your website or application before making such changes.