# text-align

## Sumário

A propriedade CSS `text-align` descreve como conteúdo inline, como texto, é alinhado no elemento pai em bloco. `text-align` não controla o alinhamento de elementos em bloco, apenas o seu conteúdo inline.

Initial value `start`, or a nameless value that acts as `left` if `direction` is `ltr`, `right` if `direction` is `rtl` if `start` is not supported by the browser. block containers yes visual as specified, except for the `match-parent` value which is calculated against its parent's `direction` value and results in a computed value of either `left` or `right` discrete order of appearance in the formal grammar of the values

## Sintaxe

```/* Keyword values */
text-align: left;
text-align: right;
text-align: center;
text-align: justify;
text-align: justify-all;
text-align: start;
text-align: end;
text-align: match-parent;

/* Block alignment values (Non-standard syntax) */
text-align: -moz-center;
text-align: -webkit-center;

/* Global values */
text-align: inherit;
text-align: initial;
text-align: unset;
```

### Valores

`start`
The same as `left` if direction is left-to-right and `right` if direction is right-to-left.
`end`
The same as `right` if direction is left-to-right and `left` if direction is right-to-left.
`left`
The inline contents are aligned to the left edge of the line box.
`right`
The inline contents are aligned to the right edge of the line box.
`center`
The inline contents are centered within the line box.
`justify`
The inline contents are justified. Text should be spaced to line up its left and right edges to the left and right edges of the line box, except for the last line.
`justify-all`
Same as `justify`, but also forces the last line to be justified.
`match-parent`
Similar to `inherit`, but the values `start` and `end` are calculated according the parent's `direction` and are replaced by the adequate `left` or `right` value.

### Sintaxe Formal

`start | end | left | right | center | justify | match-parent`

## Exemplos

### Alinhamento Esquerdo

#### HTML

```<p class="example">
Integer elementum massa at nulla placerat varius.
Suspendisse in libero risus, in interdum massa.
Vestibulum ac leo vitae metus faucibus gravida ac in neque.
Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
</p>```

#### CSS

```.example {
text-align: left;
border: solid;
}```

#### HTML

```<p class="example">
Integer elementum massa at nulla placerat varius.
Suspendisse in libero risus, in interdum massa.
Vestibulum ac leo vitae metus faucibus gravida ac in neque.
Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
</p>```

#### CSS

```.example {
text-align: center;
border: solid;
}```

#### HTML

```<p class="example">
Integer elementum massa at nulla placerat varius.
Suspendisse in libero risus, in interdum massa.
Vestibulum ac leo vitae metus faucibus gravida ac in neque.
Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
</p>```

#### CSS

```.example {
text-align: justify;
border: solid;
}```

### Notas

The standard-compatible way to center a block itself without centering its inline content is setting the left and right `margin` to `auto`, e.g.:

```.something {
margin: auto;
}
```
```.something {
margin: 0 auto;
}
```
```.something {
margin-left: auto;
margin-right: auto;
}
```

## Especificações

Especificação Status Comentário
CSS Logical Properties and Values Level 1
The definition of 'text-align' in that specification.
Rascunho editorial Sem mudanças
CSS Text Module Level 3
The definition of 'text-align' in that specification.
Rascunho atual Added the `start`, `end`, and `match-parent` values. Changed the unnamed initial value to `start` (which it was).
CSS Level 2 (Revision 1)
The definition of 'text-align' in that specification.
Recomendação Sem mudanças
CSS Level 1
The definition of 'text-align' in that specification.
Recomendação Definição iniciaç

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Suporte básico (`left`, `right`, `center` and `justify`) 1.0 (Yes) 1.0 (1.7 or earlier) 3.0 3.5 1.0 (85)
Block alignment values 1.0-webkit ? 1.0 (1.7 or earlier)-moz[1] Não suportado Não suportado 1.0 (85)-khtml
1.3 (312)-webkit [1]
`start` 1.0 ? 1.0 (1.7 or earlier) Não suportado (Yes) 3.1 (525)
`end` 1.0 ? 3.6 (1.9.2) Não suportado (Yes) 3.1 (525)
`match-parent` 16 ? 40 (40) Não suportado Não suportado Não suportado
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Suporte básico ? ? (Yes) ? ? ? ?
Block alignment values ? ? ? ? ? ? ?
`start` ? ? ? ? ? ? ?
`end` ? ? ? ? ? ? ?
`match-parent` ? ? ? 40.0 (40) ? ? ?
`true`(non-standard syntax) Não suportado Não suportado ? ? Não suportado Não suportado Não suportado

[1] 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.