Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-align: -webkit-center vs text-align: center

Tags:

Does anyone know why there is a difference between text-align: center and , text-align:-webkit-center ? For example if you have :

<section>  <h1>Title<h1>  <div class="image"></div> </section> 

// CSS with text-align: center;

section{  text-align: center;  } 

This will center just the text

// CSS with text-align: -webkit-center

section{  text-align: -webkit-center; } 

This will center the text and the image.

Same goes for text-align: -moz-center;

like image 581
Miles Avatar asked Feb 01 '16 10:02

Miles


People also ask

What is the difference between align and text-align?

More answers about "What is the difference between align and text-align?" text-align - aligns text within the element to which this property is specified. align="center" aligns the element itself, if possible. For example, pictures, tables, frames, and so on.

Which text alignment is best?

The left-aligned text results in much better content readability, so all books, articles & newspapers are written this way. The left-aligned text helps to avoid unnecessary eye jumps, making the whole copy much easier to follow.

Should you center align text?

Centered text is best used for headlines and short lines of text. Users can read them with ease because the lines are short, scannable and don't need repeated eye movements. They can also give your layout a balanced look with its symmetrical format.

What is the text-align?

Text alignment is a paragraph formatting attribute that determines the appearance of the text in a whole paragraph. For example, in a paragraph that is left-aligned (the most common alignment), text is aligned with the left margin. In a paragraph that is justified, text is aligned with both margins.


2 Answers

From the Mozilla Developer Network:

Both WebKit and Gecko support a prefixed version of left, center, and right, that applies not only to inline content but also to block elements. This is used to implement the legacy align attributes on table elements and <center>. Do not use these on production Web sites.

— MDN's documentation on text-align.

like image 159
James Donnelly Avatar answered Sep 17 '22 02:09

James Donnelly


The text-align CSS property describes how inline content like text is aligned in its parent block element. text-align does not control the alignment of block elements, only their inline content.

text-align: -moz-center; text-align: -webkit-center; 
like image 24
tesrt Avatar answered Sep 17 '22 02:09

tesrt