Results 1 to 3 of 3

Thread: width:auto question (This should be easy!)

  1. #1
    Join Date
    Oct 2005

    width:auto question (This should be easy!)

    In this page, I want the outer div (with the green border) to automatically be as small as the div within it. In this case, as small as the "hi". I have the inner div set to width:auto; margin:0 auto.

    If I set the inner div to a width, then the outer div shrinks to that width. But at width:auto, the width goes to 100%.

    This is the code:

    <div style="width:100%;text-align:center;">
    	<div style="width:auto;margin:0 auto;border:10px solid green;">
    This is the URL:


    I'd think that width:auto would tell the inner div to be only as wide as the content within it, but no. What's the workaround here? I can not set a width for this div.

    Thank you!

  2. #2
    Join Date
    Oct 2005
    (Sorry, I mistyped ... the green border is around the inner div. Regardless, what I want is for the border to just be around the little "hi" without having to set a width for the div.)

  3. #3
    Join Date
    Oct 2010
    you could do the border on the element itself

    HTML Code:
    <div style="width:100&#37;;text-align:center;">
    	<span style="border:10px solid green;">
    you could use p or h* or whatever.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles