aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/css/text-align/index.html
blob: 9789af412c5da7fb115df7b8990c0f1fdfd2ba53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
---
title: text-align
slug: Web/CSS/text-align
tags:
  - CSS
  - Propriedade CSS
  - Referencia
  - Texto CSS
translation_of: Web/CSS/text-align
---
<p>{{CSSRef}}</p>

<h2 id="Sumário">Sumário</h2>

<p><span class="seoSummary">A propriedade CSS <strong><code>text-align</code></strong> descreve como conteúdo inline, como texto, é alinhado no elemento pai em bloco. <code>text-align</code> não controla o alinhamento de elementos em bloco, apenas o seu conteúdo inline.</span></p>

<p>{{cssinfo}}</p>

<h2 id="Sintaxe">Sintaxe</h2>

<pre class="brush: css notranslate">/* 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;
</pre>

<h3 id="Valores">Valores</h3>

<dl>
 <dt><code>start</code> {{experimental_inline}}</dt>
 <dd>Igual <code>left</code> se a direção é esquerda-para-direita e <code>right</code> se a direção é direita-para-esquerda.</dd>
 <dt><code>end</code> {{experimental_inline}}</dt>
 <dd>Igual <code>right</code> se a direção é esquerda-para-direita e <code>left</code> se a direção é direita-para-esquerda.</dd>
 <dt><code>left</code></dt>
 <dd>O conteúdo é alinhado na borda esquerda do box.</dd>
 <dt><code>right</code></dt>
 <dd>O conteúdo é alinhado na borda direita do box.</dd>
 <dt><code>center</code></dt>
 <dd>Os conteúdos inline são centralizados entre a linha da caixa.</dd>
 <dt><code>justify</code></dt>
 <dd>Os conteúdos inline são justificados. 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.</dd>
 <dt><code>justify-all</code></dt>
 <dd>Semelhante a <code>justify</code>, porém força a última linha a ser justificada.</dd>
 <dt><code>match-parent</code> {{experimental_inline}}</dt>
 <dd>Similar to <code>inherit</code>, but the values <code>start</code> and <code>end</code> are calculated according the parent's {{cssxref("direction")}} and are replaced by the adequate <code>left</code> or <code>right</code> value.</dd>
</dl>

<h3 id="Sintaxe_Formal">Sintaxe Formal</h3>

<pre class="syntaxbox notranslate">{{csssyntax}}</pre>

<h2 id="Exemplos">Exemplos</h2>

<h3 id="Alinhamento_Esquerdo">Alinhamento Esquerdo</h3>

<h4 id="HTML">HTML</h4>

<pre class="brush: html notranslate">&lt;p class="example"&gt;
  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.
&lt;/p&gt;</pre>

<h4 id="CSS">CSS</h4>

<pre class="brush: css; highlight:[2] notranslate">.example {
  text-align: left;
  border: solid;
}</pre>

<h4 id="Resultado">Resultado</h4>

<p>{{EmbedLiveSample("Left_alignment","100%","100%")}}</p>

<h3 id="Texto_centralizado">Texto centralizado</h3>

<h4 id="HTML_2">HTML</h4>

<pre class="brush: html notranslate">&lt;p class="example"&gt;
  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.
&lt;/p&gt;</pre>

<h4 id="CSS_2">CSS</h4>

<pre class="brush: css; highlight:[2] notranslate">.example {
  text-align: center;
  border: solid;
}</pre>

<h4 id="Resultado_2">Resultado</h4>

<p>{{EmbedLiveSample("Centered_text","100%","100%")}}</p>

<h3 id="Justificado">Justificado</h3>

<h4 id="HTML_3">HTML</h4>

<pre class="brush: html notranslate">&lt;p class="example"&gt;
  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.
&lt;/p&gt;</pre>

<h4 id="CSS_3">CSS</h4>

<pre class="brush: css; highlight:[2] notranslate">.example {
  text-align: justify;
  border: solid;
}</pre>

<h4 id="Resultado_3">Resultado</h4>

<p>{{EmbedLiveSample("Justify","100%","100%")}}</p>

<h3 id="Notas">Notas</h3>

<p>O modo compátivel-padrão de centralizar um bloco em si sem centralizar seu conteúdo inline é setando a {{cssxref("margin")}} left e right para <code>auto</code>, e.g.:</p>

<pre class="brush: css notranslate">.something {
  margin: auto;
}
</pre>

<pre class="brush: css notranslate">.something {
  margin: 0 auto;
}
</pre>

<pre class="brush: css notranslate">.something {
  margin-left: auto;
  margin-right: auto;
}
</pre>

<h2 id="Especificações">Especificações</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Especificação</th>
   <th scope="col">Status</th>
   <th scope="col">Comentário</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS Logical Properties', '#text-align', 'text-align')}}</td>
   <td>{{Spec2('CSS Logical Properties')}}</td>
   <td>Sem mudanças</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS3 Text', '#text-align-property', 'text-align')}}</td>
   <td>{{Spec2('CSS3 Text')}}</td>
   <td>Added the <code>start</code>, <code>end</code>, and <code>match-parent</code> values. Changed the unnamed initial value to <code>start</code> (which it was).</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'text.html#alignment-prop', 'text-align')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Sem mudanças</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS1', '#text-align', 'text-align')}}</td>
   <td>{{Spec2('CSS1')}}</td>
   <td>Definição iniciaç</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibilidade">Browser compatibilidade</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Suporte básico (<code>left</code>, <code>right</code>, <code>center</code> and <code>justify</code>)</td>
   <td>1.0</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoDesktop("1.0")}}</td>
   <td>3.0</td>
   <td>3.5</td>
   <td>1.0 (85)</td>
  </tr>
  <tr>
   <td>Block alignment values {{non-standard_inline}}</td>
   <td>1.0{{property_prefix("-webkit")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("1.0")}}{{property_prefix("-moz")}}<sup>[1]</sup></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>1.0 (85){{property_prefix("-khtml")}}<br>
    1.3 (312){{property_prefix("-webkit")}} [1]</td>
  </tr>
  <tr>
   <td><code>start</code> {{experimental_inline}}</td>
   <td>1.0</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("1.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>3.1 (525)</td>
  </tr>
  <tr>
   <td><code>end</code> {{experimental_inline}}</td>
   <td>1.0</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("1.9.2")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>3.1 (525)</td>
  </tr>
  <tr>
   <td><code>match-parent</code>{{experimental_inline}}</td>
   <td>16</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("40")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td>Block alignment values {{non-standard_inline}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>start</code> {{experimental_inline}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>end</code> {{experimental_inline}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>match-parent</code>{{experimental_inline}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("40")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>true</code>(non-standard syntax){{non-standard_inline}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Both WebKit and Gecko support a prefixed version of <code>left</code>, <code>center</code>, and <code>right</code>, that applies not only to inline content but also to block elements. This is used to implement the legacy {{htmlattrxref("align", "td")}} attributes on table elements and <code>&lt;center&gt;</code>. Do not use these on production Web sites.</p>

<h2 id="Veja_também">Veja também</h2>

<ul>
 <li>{{Cssxref("margin","margin:auto")}}, {{Cssxref("margin-left","margin-left:auto")}}, {{Cssxref("vertical-align")}}</li>
</ul>