Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Align a Link HTML/CSS

I have tried to do the following, as well as using the align only with the <a> href and <img> tags, yet I still cannot align the clickable image to the center of the page.

<a href="next.html" align="middle">
   <img src="tlbr.png" align="middle">
</a>

The float tag also does not work in any way I have tried, since, as far as I am aware, there is no way to float to center.

Any solution, directly in HTML or in the CSS, would be great. Thanks.


2 Answers

Check out the demo and try like this: Demo

a img {
   margin:0 auto;    
   display:block;
}
like image 104
G.L.P Avatar answered Oct 23 '25 04:10

G.L.P


Add this code to your CSS:

a img{
   display: block;
   text-align: center;
}

JSFIDDLE DEMO

like image 35
Rahul Tripathi Avatar answered Oct 23 '25 04:10

Rahul Tripathi