What are the potential pitfalls of using HTML tables for layout in the context of responsive design?
Using HTML tables for layout in the context of responsive design can lead to rigid and inflexible designs that do not adapt well to different screen sizes. This can result in a poor user experience on mobile devices or smaller screens. To solve this issue, it is recommended to use CSS for layout and positioning, as it allows for more flexibility and control over the design.
<!DOCTYPE html>
<html>
<head>
<style>
/* CSS for responsive design */
.container {
display: flex;
flex-wrap: wrap;
}
.item {
flex: 1 0 50%; /* 2 items per row */
padding: 10px;
box-sizing: border-box;
}
@media (max-width: 768px) {
.item {
flex: 1 0 100%; /* 1 item per row on smaller screens */
}
}
</style>
</head>
<body>
<div class="container">
<div class="item">Item 1</div>
<div class="item">Item 2</div>
<div class="item">Item 3</div>
<div class="item">Item 4</div>
</div>
</body>
</html>