The basic structure of an HTML page looks like this:
<!DOCTYPE html>
<html lang="de">
<head>
<title>Seitentitel</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
content
</body>
</html>
Mehr dazu: Document structure in Learn HTML
To integrate JavaScript into an HTML file, include a script tag with the src
attribute pointing to the JavaScript file:
<script src="pfad/zum/script.js"></script>
Alternatively, you can include the JavaScript code directly in the HTML file by placing it within a script
tag:
<script>
// JavaScript code goes here
</script>
Here's an example of using JavaScript to select an HTML element and change its text content:
const myHeading = document.querySelector("h1");
myHeading.textContent = "Hello world!";