Tuesday, November 6, 2012

How To Center A Image Using [html 5] Code

For center a image in html 5 you should follow css and you can't use center html tag because it is not a valid html 5 tag. So for centering a image you can use the css code margin. Make the left and right margin as auto and top and bottom as zero.

Centering Image in html 5

Below is the code css code to make a image at center using css which is a html 5 valid method.

margin: 0px auto;display:block

If you apply the above css elements to a image it will look like the below given code

<img style="margin:0px auto;display:block" src="Image URL Here"/>

Comments (36)

Loading... Logging you in...
  • Logged in as
Thank you for the informative post. I am also from this industry, your article helps me. Keep writing on
This blog is really nice . it helps me a lot. I m doing in a same field.

Citrix Web Interface
blog is really good and knowledgeable. Thanks
Sergo Cusiani's avatar

Sergo Cusiani · 566 weeks ago

My respect!
$logo = ''. $sitename .''; not working :(
Excellent - thank you
There are so many "how to's" on the web for centering an image in HTML 5, yours is simple and it works. Thank you.
this is terrific! I was searching for a while, and a lot of people complicate this method. Works brilliantly on my desktop and mobile.
Great! Just what I needed. Thank you.
I don't write reviews, but your post made me. Hats Offf....
Nice and simple.
Cheers.
"text-align: center;" on container will work also if the container width is expressed in "%" : http://jsbin.com/corebuvile/1/edit
Pro programmer's avatar

Pro programmer · 515 weeks ago

Thank you very much!
thanks for the quick explanation, very helpful!
simple and works, not like the others. thanks.
A clear and simple explanation. The center tag is no longer necessary to integrate style sheets with the markup language and provides a more general solution of alignment. HTML5 has absorbed a large number of tags developed by third parties in the past years.
Thank you for the informative post.
Thank you. I've been trying to find a solution for hours. Yours is lovely, and minimal.
thx very much
done
Excellent
Thanks so much
Excellent
Thanks so much
Who would have thought somebody buying comments for popularity would actually be helpful?
Thanks for the post.
for easy way and learn.i think it should be this way

Post a new comment

Comments by

Find us on Google+
Bloggers.com