The scrolling attribute is used to control the visibility of scrollbars in an <iframe> element. It determines whether scrollbars should appear when the embedded content exceeds the frame size.
- Controls the display of horizontal and vertical scrollbars in the iframe.
- Common values are yes, no, and auto.
- Helps improve the appearance and usability of embedded content.
Syntax:
<iframe scrolling="auto | yes | no">Attribute Values
- auto: It has a default value. The scrollbar appears when needed.
- yes: This value shows the scrollbar in the Iframe Element.
- no: This value does not show the scrollbar in the Iframe Element.
Note: This attribute has been DEPRECATED and is no longer recommended.
Example: Implementation of <iframe> scrolling Attribute
<!--Driver Code Starts-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
text-align: center;
}
</style>
</head>
<!--Driver Code Ends-->
<body>
<h1 style="color: green;">
GeeksForGeeks
</h1>
<h2>
HTML Iframe scrolling Attribute
</h2>
<p>Content goes here</p>
<iframe src="https://en.wikipedia.org/wiki/Main_Page"
height="300" width="400"
marginwidth="50" scrolling="yes">
</iframe>
</body>
<!--Driver Code Starts-->
</html>
<!--Driver Code Ends-->
Example 2: Implementation of <iframe> scrolling with no scrolling attribute.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
text-align: center;
}
</style>
</head>
<!--Driver Code Ends-->
<body>
<h1 style="color: green;">
GeeksForGeeks
</h1>
<h2>
HTML Iframe scrolling Attribute
</h2>
<p>Content goes here</p>
<iframe src="https://en.wikipedia.org/wiki/Main_Page"
height="300" width="400"
marginwidth="50" scrolling="no">
</iframe>
</body>
<!--Driver Code Starts-->
</html>
<!--Driver Code Ends-->