Es gibt mehrere Möglichkeiten, einen HTML-Button zu erstellen, der sich wie ein Link verhält (d. h. der Benutzer wird auf die angegebene URL umgeleitet).
Sie können eine der folgenden Methoden wählen, um einen Link zu einem HTML-Button hinzuzufügen.
<!DOCTYPE html>
<html>
<head>
<title>Der Titel des Dokuments</title>
</head>
<body>
<button onclick="window.location.href = 'https://de.w3docs.com';">Hier klicken</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Der Titel des Dokuments</title>
</head>
<body>
<form>
<input type="button" onclick="window.location.href = 'https://de.w3docs.com';" value="w3docs"/>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Der Titel des Dokuments</title>
</head>
<body>
<form action="https://de.w3docs.com/">
<button type="submit">Klicken</button>
</form>
</body>
</html>
Um den Link in einem neuen Tab zu öffnen, fügen Sie das Attribut target="_blank hinzu.
<!DOCTYPE html>
<html>
<head>
<title>Der Titel des Dokuments</title>
</head>
<body>
<form action="https://de.w3docs.com/" method="get" target="_blank">
<button type="submit">Klicken</button>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Der Titel des Dokuments</title>
</head>
<body>
<form>
<button type="submit" formaction="https://de.w3docs.com">Klicken</button>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Der Titel des Dokuments</title>
<style>
.button {
background-color: #FF4500;
border: none;
color: white;
padding: 20px 34px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 4px 2px;
cursor: pointer;
}
</style>
</head>
<body>
<a href="https://de.w3docs.com/" class="button">Hier klicken</a>
</body>
</html>