Your HTML code is well-structured for displaying a simple table of links with a search function, styling, and a footer. Below are a few suggestions and improvements you might consider to enhance functionality and appearance:
Suggested Improvements:
-
Meta Description:
Add a brief description to the content of your site in the <meta name="description"> tag for better SEO.
<meta name="description" content="A directory of resources to use ChatGPT for free, including links and descriptions.">
-
Accessibility Enhancements:
- Consider adding
scope="col" to the table headers for better accessibility.
- Use
aria-describedby for your search input to provide context on its purpose.
<th scope="col">№</th>
<th scope="col">Title</th>
<th scope="col">Link</th>
<th scope="col">Description</th>
<th scope="col">API</th>
-
Styling Improvements:
- Use a lighter background for the search input for better visibility.
- Consider enhancing the hover effect on table rows for better user experience.
input[type="text"] {
background-color: #323252; /* A bit lighter for better visibility */
}
tr:hover {
background-color: #2a2a2a; /* Highlight row on hover */
}
-
Table Rows:
- If you want to visually distinguish table rows, consider alternating row colors for better readability.
tr:nth-child(even) {
background-color: #1a1a1a; /* Alternate row color */
}
-
Responsive Design:
- Add media queries to ensure the table and elements stack correctly on smaller screens.
@media (max-width: 600px) {
.logo-text {
font-size: 24px; /* Adjust logo size */
}
th, td {
font-size: 14px; /* Adjust font size for small screens */
}
}
-
JavaScript Cleanup:
- Although the sorting function is working, consider refactoring it for clarity and robustness, potentially handling numbers more gracefully if needed.
Full Example with Suggestions Implemented:
Here’s your updated HTML including the suggested improvements:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Use ChatGPT for free</title>
<meta name="description" content="A directory of resources to use ChatGPT for free, including links and descriptions.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
background-color: #040c1f;
color: #ccc;
}
table {
border-collapse: collapse;
width: 100%;
color: #ccc;
}
th, td {
text-align: left;
padding: 8px;
border-bottom: 1px solid #ddd;
border-right: 1px solid #ddd;
}
th:first-child, td:first-child {
border-left: 1px solid #ddd;
}
td:first-child {
font-weight: bold;
}
.logo-text {
font-family: Arial, sans-serif;
font-size: 36px;
font-weight: bold;
color: #fff;
padding: 10px 20px;
border-radius: 5px;
margin: 20px auto;
text-align: center;
}
.author {
text-align: center;
font-weight: bold;
margin-top: 20px;
}
.footer {
background-color: #040c1f;
color: #ccc;
text-align: center;
padding: 10px;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
}
a {
color: #81dafc;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
#search-input {
width: 100%;
margin-bottom: 10px;
padding: 10px;
box-sizing: border-box;
color: #ccc;
background-color: #323252; /* Updated for better visibility */
}
input[type="text"] {
background-color: #20203d;
border: none;
color: #ccc;
padding: 10px;
width: 100%;
box-sizing: border-box;
border-radius: 5px;
}
tr:hover {
background-color: #2a2a2a;
}
tr:nth-child(even) {
background-color: #1a1a1a;
}
@media (max-width: 600px) {
.logo-text {
font-size: 24px;
}
th, td {
font-size: 14px;
}
}
</style>
</head>
<body>
<div class="logo-text">Use ChatGPT for free</div>
<p>test</p>
<input type="text" id="search-input" placeholder="Search..." aria-label="Search in the directory">
<table role="table" aria-label="Web page table">
<thead>
<tr>
<th scope="col">№</th>
<th scope="col">Title</th>
<th scope="col">Link</th>
<th scope="col">Description</th>
<th scope="col">API</th>
</tr>
</thead>
<tbody>
<tr>
<td>1.</td>
<td><span style="display:inline-block;margin-right:5px;">⭐</span>Invidious</td>
<td><a href="https://yewtu.be" target="_blank">yewtu.be</a></td>
<td>Astronomy Picture of the Day, Mars Rover Photos, and more.</td>
<td>gpt4</td>
</tr>
<tr>
<td>2.</td>
<td>Invidious</td>
<td><a href="https://invidious.kavin.rocks" target="_blank">invidious.kavin.rocks</a></td>
<td>Astronomy Picture of the Day, Mars Rover Photos, and more.</td>
<td>gpt4</td>
</tr>
</tbody>
</table>
<div class="footer">
<p>© John Doe<br>Contact: john.doe@email.com</p>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
var headers = document.getElementsByTagName("th");
for (var i = 0; i < headers.length; i++) {
headers[i].addEventListener("click", function() {
var index = Array.prototype.indexOf.call(headers, this);
sortTable(index);
});
}
$('#search-input').on('keyup', function () {
var value = $(this).val().toLowerCase();
$('tbody tr').filter(function () {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
function sortTable(n) {
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
table = document.getElementsByTagName("table")[0];
switching = true;
dir = "asc";
while (switching) {
switching = false;
rows = table.rows;
for (i = 1; i < (rows.length - 1); i++) {
shouldSwitch = false;
x = rows[i].getElementsByTagName("TD")[n];
y = rows[i + 1].getElementsByTagName("TD")[n];
if (dir == "asc") {
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
shouldSwitch = true;
break;
}
} else if (dir == "desc") {
if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
shouldSwitch = true;
break;
}
}
}
if (shouldSwitch) {
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
switching = true;
switchcount++;
} else {
if (switchcount == 0 && dir == "asc") {
dir = "desc";
switching = true;
}
}
}
}
</script>
</body>
</html>
With these changes, your page will not only look better but also perform better and be more accessible to all users.