Jump to content
metadata

image alignment

Recommended Posts

I'm trying to align an image in my HTML document to the center of the page. In looking through the references on the W3 page I see that the align attribute is deprecated. There's a note that the CSS float property can be used (I am using an external style sheet) but it looks like it would only set things to the right or left, but not the center. Can someone point me in the direction of where I can look to solve this? Thanks :good:

Share this post


Link to post
Share on other sites

When use auto it stays on the left side. I've been trying different percentages and that seems to work better.

Share this post


Link to post
Share on other sites

Make that margin: 0 auto.

Share this post


Link to post
Share on other sites
Make that margin: 0 auto.
that doesn't seem to be working, is my code correct in my CSS?
img {margin:0 auto;}

Share this post


Link to post
Share on other sites

By default the img element is a inline element, margin: 0 auto; width: ###px; won't wotk unless you define it as block element. img {margin:0 auto; width: ###px; display:block;}

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...