Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> html { scroll-behavior: auto; } #element1 { height: 600px; background-color: #ccc; } #element2 { height: 600px; background-color: #8ebf42; } </style> </head> <body> <h2>Scroll-behavior property example</h2> <div class="main" id="element1"> <h2>Element 1</h2> <a href="#element2">Click to scroll to Element 2</a> </div> <div class="main" id="element2"> <h2>Element 2</h2> <a href="#element1">Click to scroll to Element 1</a> </div> </body> </html>