Question: I need to make sure that a specific line is visible when the user loads the page, even if that line appears many lines later in the page. In other words, when the page loads, it instantly jumps to that marked line. The line simply needs to be somewhere within the visible screen of the browser window. It is marked like this:

```
<div class="scrollhere">This line should always be visible when the page loads.</div>

```

* Only one of these appears on the whole page.
* I cannot edit the HTML marking the text, but can edit the CSS and JavaScript at the beginning of the document.
* I do not mean for just that specific line to be moved, i.e. with `position:absolute`, but that the page loads to that line.

How can I make the page load mid-way down the page, wherever a specific `<div class="scrollhere">` is found?

Answer: 
So if you can't edit the HTML at all, then you'll need to use JavaScript or jQuery. This is a function that I've used to scroll to an element.

Javascript
----------

This will query the DOM for all elements that have your class `scrollhere`. And we'll select just the first item in the array (to go to the first element). Then we'll use the [`scrollIntoView()`](https://developer.mozilla.org/en-US/docs/Web/API/Element.scrollIntoView).

```
document.getElementsByClassName('scrollhere')[0].scrollIntoView()

```

jQuery
------

```
/*
 * A scrollTo function that gets passed a selector (ID, class, element) & an optional offset
 *
 * @param {string}  location ('#resultsTop')
 * @param {integer} offset   (-100)
 */
function scrollTo(location, offset) {
    $("html, body").animate({scrollTop: ($(location).offset().top + (offset || 0) )}, "slow");
    return false;
};

```

In your case, you'd call this function as follows:

```
scrollTo('.scrollhere');

```

You could also optionally pass in an `offset`. So maybe you don't want to scroll to the top of that element. But would rather scroll to `100 pixels` above it.

```
scrollTo('.scrollhere',-100);

```

And being that you can't edit the HTML, then you'll definitely want to use a listener.

```
$(document).ready(function(){
  scrollTo('.scrollhere',-100);
});

```
This snippet may help you 

```
$('html, body').animate({
    scrollTop: ($('.class').first().offset().top)
},500);

```