Javatpoint Logo
Javatpoint Logo

How to Remove Scroll Bar in CSS

We are going to discuss how to remove the scroll bar in CSS in this article.

What is a Scroll Bar?

A scroll bar is an element that is placed at the corner of the web page. It is used to scroll the page upwards and downwards or left and right with the help of a mouse.

A scroll bar is when clicked and dragged then the content present on the web page is moved in the direction in which the scroll bar is dragged.

Nowadays, the scroll bar appears only when necessary and is hidden when not required.

We can hide the scroll bar from the web page with the help of the CSS properties.

Needs to Remove the Scroll Bar

  • The scroll bar makes the website look outdated.
  • It is not required in various website layouts.
  • It occupies extra space on the web page.

Benefits of Removing the Scroll Bar

  • We can remove the scroll bar and make the website look modern.
  • We can remove the scroll bar from layouts where it is not required.
  • We can save extra occupied space.

Ways to Remove the Scroll Bar

There are various ways in which we can remove the scroll bar from the web page.

1. Using the overflow-x property of CSS:

It is utilized to remove the horizontal scroll bar by setting the value as hidden.

Syntax:

The "overflow-x" is the CSS property with the "hidden" value.

Illustration of using the overflow-x CSS property:

We will build a registration page in this illustration. We are going to utilize "overflow-x: hidden" to remove the horizontal scroll bar.

Code:

Output:

Here, we can witness output both without overflow-x and with overflow-x.

When overflow-x is not utilized, then the output is given below. Both vertical and horizontal scroll bars are visible:

How to Remove Scroll Bar in CSS

When overflow-x is utilized then, the output is given below; only the vertical scroll bar is visible, and the horizontal scroll bar is removed:

How to Remove Scroll Bar in CSS

2. Using the overflow-y property of CSS:

It is utilized to remove the vertical scroll bar by setting the value as hidden.

Syntax:

The "overflow-y" is the CSS property with the "hidden" value.

Illustration of using the overflow-y CSS property:

We will create a login form in this illustration. We are going to utilize "overflow-y: hidden" to remove the vertical scroll bar.

Code:

Output:

Here, we can witness output both without overflow-y and with overflow-y.

When overflow-y is not utilized, then the output is given below. Both vertical and horizontal scroll bars are visible:

How to Remove Scroll Bar in CSS

When overflow-y is utilized then, the output is given below; only the horizontal scroll bar is visible, and the vertical scroll bar is removed:

How to Remove Scroll Bar in CSS

3. Using overflow property of CSS:

It is utilized to remove the horizontal scroll bar and vertical scroll bar by setting the value to hidden.

Syntax:

The "overflow" is the CSS property with the "hidden" value.

Illustration of using the overflow CSS property:

We will build a list in this illustration. We are going to utilize "overflow: hidden" to remove both the horizontal scroll bar and the vertical scroll bar.

Code:

Output:

Here we can witness output both without overflow and with overflow.

When overflow is not utilized, then the output is given below. Both vertical and horizontal scroll bars are visible:

How to Remove Scroll Bar in CSS

When overflow is utilized, then the output is given below. Both vertical and horizontal scroll bars are removed:

How to Remove Scroll Bar in CSS

Conclusion

We have comprehended how to remove the scroll bar in CSS. Some points to remember are given below:

  1. We can hide the scroll bar to create an uncluttered design, provide extra space, and make the web page look trendy.
  2. Following are the methods that we can utilize to hide the scroll bar from the website:
    • overflow-x: This property is set to "hidden" to remove the horizontal scroll bar.
    • overflow-y: This property is set to "hidden" to remove the vertical scroll bar.
    • Overflow: This property is set to "hidden" to remove the horizontal & vertical scroll bar.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA