How to center images?

TappedOut forum

Posted on May 15, 2020, 4:10 a.m. by GHOSTE666

Hi tappedout-community,

at the moment I'm really struggeling with the markdown html language of the editor. How to align center an image?

I've tried different things, centering a paragraph with the image inside. Using inline style css and so on... I don't get it. Can somebody help me please? Additional question: is there a search function for a specific forum here at tappedout?

Kind regards, GHOSTE

multimedia says... #2

Hey, can do this several ways.

<center>
<img />
</center>

Old school way of centering an HTML element by wrapping it in center tags.

<img style="display:block;margin-left:auto;margin-right:auto;" />

With CSS use the inline style by displaying the image as a block element lets you set the left and right margins to auto which aligns the image to the center.

<style>
.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
<style>

<img class="center" />

You can include a CSS rule in the HTML if that rule is wrapped in style tags. Any time you want to apply this rule to an HTML element use the inline class of center.

May 15, 2020 4:33 a.m.

Please login to comment