Jump to content

Can you help me find the error?

What the heck?

Recommended Posts

I want to create a smooth scrolling effect such that whenever someone clicks on the anchor tags, they move to the bottom without any abrupt jump. So far everything has worked for me but scroll-behavior property. Look at the code below:

<!doctype html>
  <img src="/img/lighthouse.png" width="400" height="250">
  <p scroll-behavior="smooth"><a href="https://www.itstheliar.wordpress.com">Analystfriend.com</a> is a website that provides its readers with a new perception of the topics of high importance.<a id="bnp-1"></a><a href="#np-1"><sup>[1]</sup></a> It is one of the most dynamic content driven non-organisational website at the moment.<a href="#ft-2"><sup>[2]</sup></a></p>
<p>So if you're in search of a guider or finding a way to inculcate learning in your hobbies, then you're in the right place. All you need to do is to subscribe to our newsletter and <em>relax</em>.</p> 

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc</p>

<strong>1)</strong> <a href="#bnp-1">^</a> <a href="https://en.m.wikipedia.org/wiki/Petr_Čech" id="np-1">Citation no. 1</a>
<strong>2)</strong> <a href="https://en.m.wikipedia.org/wiki/Gianluigi_Buffon" id="ft-2">Citation no. 2</a>

See the scroll-behavior property in the first paragraph tag. What is wrong with it? Why it is not working? It is scrolling in the usual way of jumping. 

Link to comment
Share on other sites

scroll-behavior is not a valid HTML attribute. If you want a link to scroll smoothly you can cancel the click event and use the scrollIntoView() method.



You must be referring to the scroll-behavior CSS property: https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior

You need to put that in a CSS stylesheet, it is not HTML. It's also not properly supported by all major browsers.

Edited by Ingolme
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...