If you need to customize a list box, the <select> HTML element might not be enough. In that case, you might want
something that simulates the behaviour of <select>.
Here is the code for a custom list box:
<html>
<head>
</head>
<body>
<div style="width: 200px; height: 200px; overflow: auto;">
<table width="100%" height="100%">
<script>
for (var i = 0; i < 30; i++) {
if (i % 2 == 0) {
document.write(
"<tr style='background-color:#0066ff; color: #ffffff'>" +
"<td>JavaScript</td></tr>");
}
else {
document.write(
"<tr style='background-color:#ff6600; color: #ffffff'>" +
"<td>JavaScript</td></tr>");
}
}
</script>
</table>
</div>
</body>
</html>
The key CSS property is overflow. If you use overflow: auto, the scrollbars are displayed only if they are needed.
If you want to display them regardless, you need to use overflow: scroll.