Creating a browser start page organized with multiple links under collapsible headings using HTML, CSS, and a bit of JavaScript is a great idea to keep everything neat and accessible. Here's a simple example to help you get started:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Start Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="category">
<div class="category-title" onclick="toggleAccordion('category1')">Category 1</div>
<div class="links" id="category1">
<a href="https://example.com/link1" target="_blank">Link 1</a>
<a href="https://example.com/link2" target="_blank">Link 2</a>
<a href="https://example.com/link3" target="_blank">Link 3</a>
</div>
</div>
<div class="category">
<div class="category-title" onclick="toggleAccordion('category2')">Category 2</div>
<div class="links" id="category2">
<a href="https://example.com/link4" target="_blank">Link 4</a>
<a href="https://example.com/link5" target="_blank">Link 5</a>
<a href="https://example.com/link6" target="_blank">Link 6</a>
</div>
</div>
<!-- Add more categories as needed -->
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css)
body {
font-family: Arial, sans-serif;
}
.container {
width: 80%;
margin: auto;
}
.category {
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 5px;
}
.category-title {
background-color: #f1f1f1;
padding: 10px;
cursor: pointer;
font-weight: bold;
border-radius: 5px 5px 0 0;
}
.links {
display: none;
padding: 10px;
border-top: 1px solid #ddd;
}
.links a {
display: block;
padding: 5px 0;
text-decoration: none;
color: #0066cc;
}
.links a:hover {
text-decoration: underline;
}
JavaScript (script.js)
function toggleAccordion(id) {
const element = document.getElementById(id);
if (element.style.display === "block") {
element.style.display = "none";
} else {
element.style.display = "block";
}
}
Explanation
-
HTML: Defines the structure of the start page.
- The container holds multiple
category div elements.
- Each category has a clickable title and a list of links wrapped in a
links div.
-
CSS: Provides basic styles.
- The
.category-title class styles the clickable headings.
- The
.links class initially hides the links until the accordion effect is triggered.
-
JavaScript: Adds interactivity.
- The
toggleAccordion function toggles the display property of the links div, showing or hiding the links when the heading is clicked.
You can add more categories by copying and pasting the category div and modifying IDs and contents as needed. This setup creates an organized and easily maintainable start page.