To redirect visitors from one page to another in HTML, you can use the HTML <meta> tag or the JavaScript window.location method.
- Using the HTML <meta> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; URL='http://example.com/page2.html'" />
</head>
<body>
<p>You will be redirected to page 2 in a moment...</p>
</body>
</html>
Explanation: In the example above, the http-equiv attribute of the <meta> tag specifies the type of HTTP header that will be returned from the server. The content attribute specifies the number of seconds before the page should be refreshed, followed by the URL to redirect to.
2. Using the JavaScript window.location method:
<!DOCTYPE html>
<html>
<head>
<script>
window.location.href = "http://example.com/page2.html";
</script>
</head>
<body>
<p>You will be redirected to page 2 in a moment...</p>
</body>
</html>