(yet another) CSS question

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
srg_13

(yet another) CSS question

Post by srg_13 »

Hi,

I have a div with one line of text in it, and I was wondering if you can set the width of that div to be the length of that text.

Is this possible? I have tried

Code: Select all

width: auto;
but that didn't work.

Thanks,

-Stephen
srg_13

Re:(yet another) CSS question

Post by srg_13 »

Is there no way I could do this???

-Stephen
whyme_t

Re:(yet another) CSS question

Post by whyme_t »

Does this work...

Code: Select all

<style type="text/css">
.shrink   { 
   background: #dfd; 
   float: left;
} 

</style>

Code: Select all

<div class="shrink">One line of text</div>
or perhaps...

Code: Select all

<div><span class="shrink">One line of spanned text</span></div>
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:(yet another) CSS question

Post by Solar »

http://en.selfhtml.org is slooooowly coming into existence - they actually translated the chapter on CSS, which you might want to check out.

(The original SelfHTML manual is in German, and respected as the #1 reference by anyone who has seen it. I have no idea why the anglos take so long to translate it - the French and Spanish translations are much better.)
Every good solution is obvious once you've found it.
Post Reply