I’m currently learning HTML. I was trying to create a simple HTML document that displays a simple table, but I’m having troubles. My web browser (Mozilla Firefox) is not displaying the borders for the whole table. It looks like if it was a regular paragraph.
Here is what I have
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0//Strict//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11-strict.dtd">
<html>
<head>
<title>My first web page</title>
</head>
<body>
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<tr/>
<tr>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>
</table>
</body>
</html>
Try adding a border attribute to the
<table>tag, like this:Edit: If you have seen tables with borders, but without the border attribute set, it’s probably because they were styled with css, which is the preferred way to style everything in html (not by adding individual attributes as above):
As another learning exercise, you should also look into linking to an external style sheet, as an alternative to using a
<style>tag in the html as shown here. Here is a decent beginning tutorial: http://www.w3schools.com/css/css_howto.asp