How To Centre An Image In HTML

HTML is a markup language that lets you create a completely functional website and add contents such as text, images, audio, video, animations and much more. You can also make necessary changes to web pages that fits your needs and likes.

There are, in fact, plenty of things that can be done in a website that is built on the HTML platform. For instance, you can add and replace various types of contents and even move them from one place to another with ease. Also, you do not have to deal with several lines of code, as some of them are manipulated with just a single line of coding.


In HTML, ‘tags’ are used to place codes and other supported programming languages, scripting languages etc., which are used to render contents in a website. These tags have a default syntax and are always enclosed in angular brackets (<></>).

So, let’s say, you have built a website using the HTML markup language and want to make a few changes here and there, just to get things in the proper order, or something that you want to be satisfied with. This blog will help you accomplish the task of placing an image in the centre position in your website thus, making your site look more attractive and interesting to your online visitors.

Methods For Placing An Image At The Centre In HTML

Here is a quick guide on how you can place an image in the centre of your web pages using HTML coding and tags.

There are basically three different methods that allow you to reposition an image file in an HTML-based website. Let’s go ahead and see what these methods are and how these can be used to accomplish the required task.

  1. Using style attribute
  2. Converting to a block-level element
  3. Using centre tags

Method #1: Using Style Attribute

HTML5 supports the use of style attribute for the purpose of aligning an image file in the centre of a website.

The following is the syntax that will help you place your selected image file in the centre of the website.

<p style=”text-align:center;”><img src=”yourpicture.jpg” alt=”PictureName”></p>

You can also add other attributes, like the height and width of the image you want in your website. These attributes should be followed after the ‘Alt’ attribute in the inline <img> element as stated in the above syntax.

Method #2: Converting To A Block-level Element

This method requires you to add a rule, either at the beginning (or head of page) or in a locally imported CSS file.

The syntax to be added to the head of the page is as follows:

<style type=”text/css”> .centerImage { text-align:center; display:block; } </style>

The ‘centerImage’ class has been nested in the block-level element. You can use this for placing multiple image files.

<img src=”yourpicture.jpg” class=”centerImage” alt=”PictureName” height=”100” width=”200”>

Method #3: Using Center (<center></center>) Tags

This is yet another simple way to place images in the centre of your web pages in your HTML website. To do this, just add the following syntax:

<center><img src=”yourpicture.jpg” alt=”PictureName” height=”100” width=”200”></center>

As you can see, there is a slight difference in the syntax, where the ‘center’ tags are used outside the ‘img’ tag in order to place the desired image in the centre of your website.

Need More Help? Contact Codexoxo For Support

The methods that are mentioned above will help you do just what you want and get the desired results without having to put in much effort.

If you need additional support or guidance with regards to modifying image positions in your website, we can help you. Simply reach us by dialling our toll-free help desk phone number <enter-phone-number> and our experts will assist you with all the solutions you need, so that you get the best experience from of your website.

Call Now