How to vertically align image in .ePub?

No Comments

Here’s a sample code to align image vertically in .ePub

Step1: Open your .ePub file in Sigil or similar software.

Step 2: Go to “Styles” folder. Add this code to your .css file.


img.verticalCenter {

width: 100%;

max-height: 50%;

margin-top: 40%;

margin-bottom: 30%;


Step 3: Open your HTML file with image to be aligned vertically. Change your code as following:


<p style=”text-align: center;”>

<img alt=”index-15″ class=”verticalCenter” src=”../Images/index-15_1.jpg”/>


Note: Text-align:center will center the image horizontally.

Step 4: Add the following code to <head> tag in order to avoid the overflow:


<style type=”text/css”>

@page {padding: 0pt; margin:0pt}

body { text-align: center; padding:0pt; margin: 0pt }

p { padding:0pt; margin: 0pt }

img { padding:0pt; margin: 0pt }


Step 5: Save your .ePub file to view the changes.



How to give top margin in Kindle?

Unfortunately, this will not work for Kindle devices. So for Kindle, we can put some margin on top of the text, like:





This will also give result. But margin from top will depend upon the length of target text.



This is author biographical info, that can be used to tell more about you, your iterests, background and experience. You can change it on Admin > Users > Your Profile > Biographical Info page."

About us and this blog

We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

Request a free quote

We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

More from our blog

See all posts