Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center div in Microsoft Outlook

Tags:

I used <div style="width: 742px; margin: 0px auto; "> to center the container div.

In the browser it works, but when I open it in Microsoft Outlook it's not in the center.

I also used !important on the margin because I thought it took precedence over the CSS.

How do I center a div in the browser and email?

like image 407
Maarten Kuilman Avatar asked Apr 13 '12 08:04

Maarten Kuilman


People also ask

Does Outlook support DIV tag?

Desktop versions of Outlook don't support the styling of <div> tags.

How do I center a div screen?

You can do this by setting the display property to “flex.” Then define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.


2 Answers

<div align="center">  your code   </div> 

Only for Outlook

like image 196
Rohit Azad Malik Avatar answered Oct 03 '22 00:10

Rohit Azad Malik


For emailing in general it is better to do use html attributes and deprecated tags instead of their CSS equivalents because some messaging systems ignore inline styles.

For example, instead of:

<div style="width: 742px; margin: 0px auto; ">... 

You can use:

<body align="center"><table align="center" width="742">... 

Or

<div align="center">... 

Example 2, instead of:

<p style="font-family: Arial, Helvetica, Tahoma, sans-serif;">My text</p> 

You can do:

<font face="Arial" size="4">My text</font> 
like image 20
Tacquet Benjamin Avatar answered Oct 03 '22 01:10

Tacquet Benjamin