4
$\begingroup$

When one attaches an image to the body of a post, like so—

enter image description here

—it automatically takes up the entire width of the body of the text.

Is there any way that this can be manually altered? For example, perhaps I would like to make the image extend through only 75% of the post’s width and centre it.

$\endgroup$
8
$\begingroup$

I'm the wrong person to tell the whole story, but I know that you can resize images by using an appropriate HTML img attribute.

Below I reuse an animation that is a small part of an answer of mine from main.

First 200 pixels wide <img src="http://i.stack.imgur.com/dIISR.gif" width="200">

Then resized <img src="http://i.stack.imgur.com/dIISR.gif" width="300">

You can specify width or height. Feel free to experiment!


According to that page it should be possible to add horizontal space around the image by specifying the attribute hspace, but that feature is not supported in HTML5. We need a more internet-savvy person to interpret the meaning of that. Anyway, I could not make it work here.

Also, I'm afraid I don't know how to make the size relative to the page width. Quote: In HTML 4.01, the width could be defined in pixels or in % of the containing element. In HTML5, the value must be in pixels. It feels strange to me that a feature is dropped from a later version of the language, but I suspect this sentiment tells more about me than about the development of HTML.


See here for a list of HTML tags allowed/supported in StackExchange. Scroll a bit further down to see which img attributes are supported. Note that neither style nor hspace is supported.

$\endgroup$
  • $\begingroup$ Clicking the next link gave the suggestion to use the tag style="margin 0px 50px" to add 50 pixel margins. Does not work here. $\endgroup$ – Jyrki Lahtonen Mar 28 at 4:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .