VOOZH about

URL: https://www.geeksforgeeks.org/html/html-onscroll-attribute/

⇱ HTML onscroll Attribute - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML onscroll Attribute

Last Updated : 11 Jul, 2025

The onscroll attribute works when an element scrollbar is being scrolled. To create a scrollbar in an element, use the CSSoverflow property.

It is triggered when the content within an HTML element is scrolled and used to implement dynamic behaviors based on the scroll position and employed for creating effects like parallax scrolling or revealing elements.

Syntax:

<element onscroll = "script">

Supported Tags

It supports all HTML elements. 

Attributes:

This attribute is supported by all HTML elements and the attribute works when the script is triggered.

Example:

In this example, we will see the implementation of the onscroll tag with an example.

Output:


Example2 :In this example, we will see the implementation of the above onscroll with an example.

Output:


Supported Browsers:

Comment
Article Tags: