/    Sign up×
Community /Pin to ProfileBookmark

Box size dictated by text?

Hi everyone,
what I need is a “box” who’s width is dictated by the text it contains. I don’t know of a way of doing that other than using a table with one cell that contains the text. I need to be able to set the padding in CSS, so:

<table class=”blah”>
<tr>
<td>HELLO</td>
</tr>
</table>

.blah{padding:blah blah blah blah;}

Surely there must be a better way than using a table??

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 24.2005 — What is the limiting factor, height or width?
Copy linkTweet thisAlerts:
@SuzanneBauthorMay 24.2005 — Hi Fang!

Width.

I want the width the padding larger than the text.
Copy linkTweet thisAlerts:
@FangMay 24.2005 — &lt;p style="float:left; white-space:nowrap; padding:3px; border:1px solid blue;"&gt;Surely there must be a better way than using a table??&lt;/p&gt;
Copy linkTweet thisAlerts:
@SuzanneBauthorMay 24.2005 — Oh, use a p! Yes. I wasn't thinking of that - you are right.
×

Success!

Help @SuzanneB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...