Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 59415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:00:06+00:00 2026-05-10T18:00:06+00:00

In the following HTML, I’d like the frame around the image to be snug

  • 0

In the following HTML, I’d like the frame around the image to be snug — not to stretch out and take up all the available width in the parent container. I know there are a couple of ways to do this (including horrible things like manually setting its width to a particular number of pixels), but what is the right way?

Edit: One answer suggests I turn off ‘display:block’ — but this causes the rendering to look malformed in every browser I’ve tested it in. Is there a way to get a nice-looking rendering with ‘display:block’ off?

Edit: If I add ‘float: left’ to the pictureframe and ‘clear:both’ to the P tag, it looks great. But I don’t always want these frames floated to the left. Is there a more direct way to accomplish whatever ‘float’ is doing?

.pictureframe {   display: block;   margin: 5px;   padding: 5px;   border: solid brown 2px;   background-color: #ffeecc; } #foo {   border: solid blue 2px;   float: left; } img {   display: block; }
<div id='foo'>   <span class='pictureframe'>        <img alt=''         src='http://stackoverflow.com/favicon.ico' />   </span>   <p>     Why is the beige rectangle so wide?   </p> </div>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:00:07+00:00Added an answer on May 10, 2026 at 6:00 pm

    The right way is to use:

    .pictureframe {     display: inline-block; } 

    Edit: Floating the element also produces the same effect, this is because floating elements use the same shrink-to-fit algorithm for determining the width.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html table <table id={64ED3A94-5833-4CC7-869F-CCE583B498BE} class=ms-listviewtable width=100% cellspacing=0 cellpadding=1 border=0 xmlns:o=urn:schemas-microsoft-com:office:office
The following HTML does not work in IE6 for me: <!DOCTYPE HTML PUBLIC "-//W3C//DTD
Given following HTML <select name="IBE1$IBE_NurFlug1$ddl_Abflughafen" id="IBE1_IBE_NurFlug1_ddl_Abflughafen" class="dropdownlist" style="width: 99%;"> <option value="Antalya;TR">Antalya</option> <option value="Berlin;DE">Berlin</option> <option
I have the following HTML: <input type=text id=endDateEditBox value= style=margin-left:5px; height:18px; width:70px; vertical-align:middle; onchange=validateDate('endDateEditBox',
Open the following HTML in Firefox <!doctype html> <html> <body> <div style=width: 1000px; height:
Following HTML block: <html> <body> <div style=background-color: #fecfff;> <div style=float:left;> <div style=height:40px; width:40px; background-color:Red>
I have following html codes <div align=center style=width:1000px;border:1px solid green;> <div style=border:1px solid red;float:left;
Consider the following html: <div class=image> <img src=sample.png/> <div class=text> Text of variable length
I have the following HTML code: <div class=outer_container> <div id=imgContainer> <img src=/some/image /> </div>
Given the following HTML, how can I select all of the 1st-generation UL tags

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.