<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
body{
height: 1500px;
}
div{
position: -webkit-sticky;
position: sticky;
top: 0;
padding: 5px;
background-color: #bfbfbf;
border: 2px solid black;
}
</style>
</head>
<body>
<h1>CSS position Property</h1>
<p>This is first paragraph.</p>
<p>This is second paragraph.</p>
<p>This is third paragraph.</p>
<div>
I will stick, when I reach the top of the page.
</div>
<p><strong>Note</strong>: Try to scroll the page.</p> </body>
</html>