All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

Disable Horizontal Scroll CSS

Last Updated : Mar 11, 2024

Disable Horizontal Scroll CSS

In this tutorial we will show you the solution of disable horizontal scroll CSS, sometimes as we see in some webpages, (it does not matter is they live or local) that they are a horizontal scrollbar. Then we see is no any content is outside dimensions and nothing special in code is used, then why it appears.

At this situation, we simply want to remove this scrollbar without any additional changes. So, how to done this/ how to remove this horizontal scrollbar, we will see in this article.

Step By Step Guide On Disable Horizontal Scroll CSS :-

In some online articles/ tutorials, we see that they suggest us to use overflow property of CSS to hide horizontal as well as vertical scrollbar, but that is not appropriate way.

When we use this overflow hidden in our codes, we see that this disabling horizontal as well as vertical scroll, so how to disable only horizontal scroll. Let us understand this with help of example.

<!DOCTYPE html>
   <title> disable horizontal scroll CSS </title>
   width: 10000px;
   height: 10000px;
   overflow-x: hidden;
 TalkersCcode – CSS tutorials
 Disable horizontal Scroll CSS
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.
Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.
Aenean nec lorem. In porttitor. Donec laoreet nonummy augue.
Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.
  1. As, here we see that we that in above example we show you an example in which HTML and CSS codes are used.
  2. Here, first of all, we create a basic structure of HTML, in which we use <!DOCTYPE html> which defines the type of document. And next one is our HTML tags. These tags are paired tags and all the data regarding HTML is written inside these tags.
  3. After we use our head tag which is again paired tag and contains the title and meta information of the webpage. The data written inside the head is not shown on the webpage.
  4. Now, next is our title tag which defines the title of the webpage. The tag which has its closing tag is known as a paired tag. So, this is again a paired tag.
  5. Now, next is the body which is the main tag of HTML. The data which we have written inside the body is shown on the webpage. Mostly all tags which are helpful to show data or information on the screen are written under the body tag.
  6. As, we see that in styles we use only overflow-x property with hidden value to disable to horizontal scroll using CSS. This helps us to disable horizontal scrolling, we hope with the help of these steps we are able to understand the above codes easily.

Conclusion :-

At last, in conclusion, here we can say that with the help of this article we are able to understand how to disable horizontal scroll using CSS.

I hope this tutorial on disable horizontal scroll CSS helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Ashish

Ashish is a dynamic and motivated individual with a passion of programming and an experienced programmer having 3+ years of experience in various languages like Java, Python, HTML, CSS, JavaScript, jQuery and various frameworks like Bootstrap

Follow Ashish On Linkedin 🡪