Vaibhav_Chhabra2 Vaibhav_Chhabra2 - 8 months ago 27
Javascript Question

HTML5 Anchors not working

I am working in HTML5 and this is my code and i am following this tutorial-
https://www.youtube.com/watch?v=kDyJN7qQETA

The code -

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<body>
<article>Hello</article>
<meta name="description" content="Vaibhav chhabra"/>


<a name="pageTop">Top of page</a>

<a href="html5.html#pageBottom">Bottom of page</a>

<br><br><br>
<a href="youtube.com" title="Youtube Site website Titile" >Youtbe alone</a>

<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>

<p>Hello Worlddddd22222222dddddd</p>
<a href="html5.html#pageTop">Top of Page</a>
<a id="pageBottom">Bottom of page</a><br>
</body>
</head>
</html>


When i click on Page Bottom Hyperlink instead of taking me to the bottom of the page , it takes me to Page not found error ,same is the problem with Page Top.
Plz help

Answer

Basic HTML:

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body> <!--Emphasis on the opening body tag and that is outside the <head></head> section -->

<h1></h1>
<p></p>

</body>
</html>

Creating an Anchor Tag.

The name attribute allows an anchor tag to be used to point to a specific place on a web page.

<a name="top"></a>
<a href="#top">Top</a>