user488792
user488792

Reputation: 2013

Blank spaces in HTML table?

I'm new to HTML and I'm wondering if there are efficient ways other than brute force using white-spaces to create the following sample table:

enter image description here

I've tried making it but the code was not pretty. I would appreciate much of your help and tips.

Upvotes: 3

Views: 14202

Answers (2)

Richard H
Richard H

Reputation: 39135

HTML:

<table>
  <tr><td class="lcol"></td><td class="mcol"></td><td class="rcol"></td></tr>
  <tr><td class="mrow"></td><td></td><td></td></tr>
  <tr><td class="brow"></td><td></td><td></td></tr>
</table>

CSS:

.lcol { width: 40px; height: 40px; }
.mcol { width: 400px; }
.rcol { width: 40px; }
.mrow { height: 400px; }
.brow { height: 40px; }

Obviously adjust the pixel sizes as required. You can use "%" too if you want to fit to page.

Edit: If you want the borders displayed, then in css:

table { border-collapse: collapse; border: 1px solid #000; }
td { border: 1px solid #000; margin: 0; }

Upvotes: 6

4b0
4b0

Reputation: 22321

why not use &nbsp;.It is the entity used to represent a non-breaking space. It is essentially a standard space, the primary difference being that a browser should not break (or wrap) a line of text at the point that this occupies.

Upvotes: 1

Related Questions