Is there a way to have a checkbox automatically checked when the page loads, causing a menu bar to be initially hidden? How can this be achieved using HTML and CSS?
Below is my current HTML and CSS code:
header #toggler:checked ~ .navbar{
clip-path:polygon(0 0, 100% 0, 100% 0, 0 0);
}
header .navbar a{
display: block;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The CheeseCake Shop</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<input type="checkbox" name="" id="toggler" checked>
<label for="toggler" class="fas fa-bars"></label>
<nav class="navbar">
<a href="#home">Home</a>
<a href="#about">About</a>
<a href="#products">Products</a>
<a href="#contact">Contact</a>
</nav>
</header>
</body>
</html>