I have a long, single page website with sections contained within <div id="#">
. Currently, the site loads/opens near the bottom between #services
and #contact
. How can I have the page always load at the top when the URL is input directly, or when clicking on a link?
Asked
Active
Viewed 142 times
1

AMC
- 1,603
- 11
- 43
- 74
-
3Have you tried disabling all your JavaScripts to see if it could be one of them causing the jump? – j08691 Mar 17 '13 at 19:26
-
This probably isn't causing your issue, but `#` isn't a valid character for the `id` attribute. See [this](http://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html) – fuzic Mar 17 '13 at 19:28
-
@fuzic I'm aware; I used `#` in this instance as a placeholder instead of listing out all of my divs. If you take a look at my code, you'll see this to be the case. – AMC Mar 17 '13 at 20:09
2 Answers
5
It is because you have the autofocus attribute set (like so: autofocus="autofocus"
) on your name input in the contact section near the bottom of the page.

Simon C
- 9,458
- 3
- 36
- 55
0
This has nothing to do with your <div id="#">
s. The reason your site doesn't start at the top is because of your contactform. Your name input field has autofocus="autofocus"
, when something is focussed the browser will scroll to this position.
Just change
<input type="text" id="name" name="name" value="" placeholder="NAME" required="required" autofocus="autofocus">
in
<input type="text" id="name" name="name" value="" placeholder="NAME" required="required">

user2019515
- 4,495
- 1
- 29
- 42