Tables as rectangular screen areas

D

dfloss

This is bad form, but it works. Is there a better way to border-ize a
rectangle of unknown size?

<html>
<body>
<div>
<table style="margin-left: auto; margin-right: auto; border-bottom:
2px solid; border-color: #999" cellspacing="0" cellpadding="0">
<tr style="font-size: x-large; font-weight: bold"><td>Here is some
text</td></tr>
<tr style="font-size: xx-small"><td>&nbsp;</td></tr>
</table>
</div>
</body>
</html>

.... insert spacers as needed
 
D

dorayme

dfloss said:
This is bad form, but it works. Is there a better way to border-ize a
rectangle of unknown size?

<html>
<body>
<div>
<table style="margin-left: auto; margin-right: auto; border-bottom:
2px solid; border-color: #999" cellspacing="0" cellpadding="0">
<tr style="font-size: x-large; font-weight: bold"><td>Here is some
text</td></tr>
<tr style="font-size: xx-small"><td>&nbsp;</td></tr>
</table>
</div>
</body>
</html>

... insert spacers as needed


Perhaps you are having trouble styling a div the way you want
because a div is by default 100% wide, even if the content is
not. The div does not naturally shrink to the width of the
content. To make it do so, one method is to estimate the width of
the content - if it is text, em based width is pretty good - and
then assign similar to a width specification to the div (with
appropriate allowances like padding, perhaps a bit to spare etc).


<div style="margin-left: auto; margin-right: auto; border-bottom:
2px #999 solid;width:9em;">
Here is some text
</div>
 
H

Harlan Messinger

dorayme said:
Perhaps you are having trouble styling a div the way you want
because a div is by default 100% wide, even if the content is
not. The div does not naturally shrink to the width of the
content. To make it do so, one method is to estimate the width of
the content - if it is text, em based width is pretty good - and
then assign similar to a width specification to the div (with
appropriate allowances like padding, perhaps a bit to spare etc).

Or if the goal is to have it look as though it occupies a particular
proportion of the window's width, use a percentage:

width: 50%;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top