LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » HTML Codes / HTML-CSS-PHP-JavaScript » How To Center An Image Or DIV To Horizontally Using HTML5?

How To Center An Image Or DIV To Horizontally Using HTML5?

How To Center An Image Or DIV Using HTML5?

If You Want To Center An Image Or A DIV In HTML File. You Have Two Ways To Place That In Center, One Is Simple And A HTML Tag But It’s Not Valid For HTML 5, As There Is A Major UpDate In HTML Version, So Many Of Professional WebMaster Are Leaving Old Style Because That Is Also Against Valid Rules And Give You Error If You Ty To Validate Your Code, So Use The New Code To Center It That Is A CSS Code. I Am Providing You Both Code And Now It’s UpTo You What You Use.

Use Any Method From The Following Methods To Center An Image Or A DIV, I Prefer To Use HTML5 Valid Syntax (Second Method). For This You Need To Add CSS Attributes To IMG Or DIV Tag. You Can Also Add Border To Image And Many Other Effects Using CSS With HTML. It Is Also Best For SEO Because After Many Updates In SEO, It’s Also A Targeted Factor For Better SEO.

Two Methods To Center Horizontally An Image In WebPage:

1.) Using Center Tag, This Is Not HTML5 Valid Syntax. But This Code Center An Image.

<center><img src="ImageURL" alt="Alt Text" title="Image Title" width="128" height="128"/></center>

2.) By Adding CSS Attribues Auto Margin And Block Display (Image Is An Inline Element Change It To Block Element). This Is HTML5 Valid Syntax.

<img style="margin:0px auto;display:block" src="ImageURL" alt="Alt Text" title="Image Title" width="128" height="128"/>

Two Methods To Center Horizontally A DIV In WebPage:

1.) Using Center Tag, This Is Not HTML5 Valid Syntax. But This Code Center An DIV.

<center><div>Your DIV Data</div></center>

2.) By Adding CSS Attribues Auto Margin And Block Display (Image Is An Inline Element Change It To Block Element). This Is HTML5 Valid Syntax.

<div style="margin:0px auto;display:block">Your DIV Data</div>

Conclusion:

No it’s up to you what you want to use to center your object, I am here only to clear the difference not to pressurize you, thanks for reading this, please leave your views and quires in the comment section.

Recommended For You:
How To Create An HTML Working Contact Form For Your Blog & Website

You Like It, Please Share This Recipe With Your Friends Using...

2 Responses to “How To Center An Image Or DIV To Horizontally Using HTML5?”

  1. Hi, I am very impressive with your post. I often get problem with place an Image horizontally in the center by using HTML5; and your sharing info is indeed my savor. Thank a lot!

Leave a Reply

Your email address will not be published. Required fields are marked *