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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
---
title: Sintexe do valor
slug: Web/CSS/Value_definition_syntax
tags:
- CSS
- Guía
- Iniciante
- Web
translation_of: Web/CSS/Value_definition_syntax
original_slug: Web/CSS/Sintexe_valor
---
<div>{{CSSRef}}</div>
<p><span class="seoSummary"><strong>CSS value definition syntax</strong>, a formal grammar, is used for defining the set of valid values for a CSS property or function.</span> In addition to this syntax, the set of valid values can be further restricted by semantic constraints (for example, for a number to be strictly positive).</p>
<p class="summary">The definition syntax describes which values are allowed and the interactions between them. A component can be a <em>keyword</em>, some characters considered as a <em>literal</em>, or a value of a given CSS data type or of another CSS property.</p>
<h2 id="Tipos_de_componente"><span class="short_text" id="result_box" lang="pt"><span>Tipos de componente</span></span></h2>
<h3 id="Keywords">Keywords</h3>
<h4 id="Generic_keywords">Generic keywords</h4>
<p>A keyword with a predefined meaning appears literally, without quotation marks. For example: <code>auto</code>, <code>smaller</code> or <code>ease-in</code>.</p>
<h4 id="The_specific_case_of_inherit_initial_and_unset">The specific case of <code>inherit</code>, <code>initial</code> and <code>unset</code></h4>
<p>All CSS properties accept the keywords <code>inherit</code>, <code>initial</code> and <code>unset</code>, that are defined throughout CSS. They are not shown in the value definition, and are implicitly defined.</p>
<h3 id="Literals">Literals</h3>
<p>In CSS, a few characters can appear on their own, like the slash ('<code>/</code>') or the comma ('<code>,</code>'), and are used in a property definition to separate its parts. The comma is often used to separate values in enumerations, or parameters in mathematical-like functions; the slash often separates parts of the value that are semantically different, but have a common syntax. Typically, the slash is used in shorthand properties; to separate component that are of the same type, but belong to different properties.</p>
<p>Both symbols appear literally in a value definition.</p>
<h3 id="Data_types">Data types</h3>
<h4 id="Basic_data_types">Basic data types</h4>
<p>Some kind of data are used throughout CSS, and are defined once for all values in the specification. Called <em>basic data types</em>, they are represented with their name surrounded by the symbol '<code><</code>' and '<code>></code>': {{ cssxref("<angle>") }}, {{cssxref("<string>")}}, …</p>
<h4 id="Non-terminal_data_types">Non-terminal data types</h4>
<p>Less common data types, called <em>non-terminal data types</em>, are also surrounded by '<code><</code>' and '<code>></code>'.</p>
<p>Non-terminal data types are of two kinds:</p>
<ul>
<li>data types <em>sharing the same name of a property</em>, put between quotes. In this case, the data type shares the same set of values as the property. They are often used in the definition of shorthand properties.</li>
<li>data type <em>not sharing the same name of a property</em>. These data types are very close to the basic data types. They only differ from the basic data types in the physical location of their definition. In this case, the definition is usually physically very close to the definition of the property using them.</li>
</ul>
<h2 id="Component_value_combinators">Component value combinators</h2>
<h3 id="Brackets">Brackets</h3>
<p><em>Brackets</em> enclose several entities, combinators, and multipliers, then transform them as a single component. They are used to <strong>group components to bypass the precedence rules</strong>.</p>
<pre class="syntaxbox">bold [ thin && <length> ]</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold thin 2vh</code></li>
<li><code>bold 0 thin</code></li>
<li><code>bold thin 3.5em</code></li>
</ul>
<p>But not:</p>
<ul>
<li><code>thin bold 3em</code>, as <code>bold</code> is juxtaposed with the component defined by the brackets, it must appear before it.</li>
</ul>
<h3 id="Juxtaposition">Juxtaposition</h3>
<p>Placing several keywords, literals or data types, next to one another, only separated by one or several spaces, is called <em>juxtaposition</em>. All juxtaposed components are <strong>mandatory and should appear in the exact order</strong>.</p>
<pre class="syntaxbox">bold <length> , thin
</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold 1em, thin</code></li>
<li><code>bold 0, thin</code></li>
<li><code>bold 2.5cm, thin</code></li>
<li><code>bold 3vh, thin</code></li>
</ul>
<p>But not:</p>
<ul>
<li><code>thin 1em, bold</code>, as the entities must be in the expressed order</li>
<li><code>bold 1em thin</code>, as the entities are mandatory; the comma, a literal, must be present</li>
<li><code>bold 0.5ms, thin</code>, as the <code>ms</code> values are not {{cssxref("<length>")}}</li>
</ul>
<h3 id="Double_ampersand">Double ampersand</h3>
<p>Separating two or more components, by a <em>double ampersand</em>, <code>&&</code>, means that all these entities are <strong>mandatory but may appear in any order</strong>.</p>
<pre class="syntaxbox">bold && <length>
</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold 1em</code></li>
<li><code>bold 0</code></li>
<li><code>2.5cm bold</code></li>
<li><code>3vh bold</code></li>
</ul>
<p>But not:</p>
<ul>
<li><code>bold</code>, as both components must appear in the value.</li>
<li><code>bold 1em bold</code>, as both components must appear only one time.</li>
</ul>
<div class="note"><strong>Note:</strong> juxtaposition has precedence over the double ampersand, meaning that <code>bold thin && <length></code> is equivalent to <code>[ bold thin ] && <length></code>. It describes <code>bold thin <length></code> or <code><length> bold thin</code> but not <code>bold <length> thin</code>.</div>
<h3 id="Double_bar">Double bar</h3>
<p>Separating two or more components by a <em>double bar</em>, <code>||</code>, means that all entities are options: <strong>at least one of them must be present, and they may appear in any order</strong>. Typically this is used to define the different values of a <a href="/en-US/docs/Web/CSS/Shorthand_properties">shorthand property</a>.</p>
<pre class="syntaxbox"><'border-width'> || <'border-style'> || <'border-color'>
</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>1em solid blue</code></li>
<li><code>blue 1em</code></li>
<li><code>solid 1px yellow</code></li>
</ul>
<p>But not:</p>
<ul>
<li><code>blue yellow</code>, as a component must appear at most one single time.</li>
<li><code>bold</code>, as it isn't a keyword allowed as value of any of the entity.</li>
</ul>
<div class="note"><strong>Note:</strong> the double ampersand has precedence over the double bar, meaning that <code>bold || thin && <length></code> is equivalent to <code>bold || [ thin && <length> ]</code>. It describes <code>bold</code>, <code>thin <length></code>, <code>bold thin <length></code>, or <code>thin <length> bold</code> but not <code><length> bold thin</code> as bold, if not omitted, must be placed before or after the whole <code>thin && <length></code> component.</div>
<h3 id="Single_bar">Single bar</h3>
<p>Separating two or more entities by a <em>single bar</em>, <code>|</code>, means that all entities are exclusive options: <strong>exactly one of these options must be present</strong>. This is typically used to separate a list of possible keywords.</p>
<pre class="syntaxbox"><percentage> | <length> | left | center | right | top | bottom</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>3%</code></li>
<li><code>0</code></li>
<li><code>3.5em</code></li>
<li><code>left</code></li>
<li><code>center</code></li>
<li><code>right</code></li>
<li><code>top</code></li>
<li><code>bottom</code></li>
</ul>
<p>But not:</p>
<ul>
<li><code>center 3%</code>, as only one of the components must be present.</li>
<li><code>3em 4.5em</code>, as a component must be present at most one time.</li>
</ul>
<div class="note">
<p><strong>Note:</strong> the double bar has precedence over the single bar, meaning that <code>bold | thin || <length></code> is equivalent to <code>bold | [ thin || <length> ]</code>. It describes <code>bold</code>, <code>thin</code>, <code><length></code>, <code><length> thin</code>, or <code>thin <length> </code>but not <code>bold <length></code> as only one entity from each side of the <code>|</code> combinator can be present.</p>
</div>
<h2 id="Component_value_multipliers">Component value multipliers</h2>
<p>A multiplier is a sign that indicate how many times a preceding entity can be repeated. Without a multiplier, an entity must appear exactly one time.</p>
<p>Note that multipliers cannot be added and have all precedence over combinators.</p>
<h3 id="Asterisk_(*)">Asterisk (<code>*</code>)</h3>
<p>The <em>asterisk multiplier</em> indicates that the entity may appear <strong>zero, one or several times</strong>.</p>
<pre class="syntaxbox">bold smaller*</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold</code></li>
<li><code>bold smaller</code></li>
<li><code>bold smaller smaller</code></li>
<li><code>bold smaller smaller smaller</code>, and so on.</li>
</ul>
<p>But not:</p>
<ul>
<li><code>smaller</code>, as <code>bold</code> is juxtaposed, and must appear before any <code>smaller</code> keyword.</li>
</ul>
<h3 id="Plus_()">Plus (<code>+</code>)</h3>
<p>The <em>plus multiplier</em> indicates that the entity may appear <strong>one or several times</strong>.</p>
<pre class="syntaxbox">bold smaller+</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold smaller</code></li>
<li><code>bold smaller smaller</code></li>
<li><code>bold smaller smaller smaller</code>, and so on.</li>
</ul>
<p>But not:</p>
<ul>
<li><code>bold</code>, as <code>smaller</code> must appear at least one time.</li>
<li><code>smaller</code>, as <code>bold</code> is juxtaposed and must appear before any <code>smaller</code> keyword.</li>
</ul>
<h3 id="Question_mark_()">Question mark (<code>?</code>)</h3>
<p>The <em>question mark multiplier</em> indicates that the entity is optional, and <strong>must appear zero or one time</strong>.</p>
<pre class="syntaxbox">bold smaller?</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold</code></li>
<li><code>bold smaller</code></li>
</ul>
<p>But not:</p>
<ul>
<li><code>bold smaller smaller</code>, as <code>smaller</code> must appear at most one time.</li>
<li><code>smaller</code>, as <code>bold</code> is juxtaposed and must appear before any <code>smaller</code> keyword.</li>
</ul>
<h3 id="Curly_braces_(_)">Curly braces (<code>{ }</code>)</h3>
<p>The <em>curly braces multiplier</em>, enclosing two integers separated by a comma, A and B, indicates that the entity <strong>must appear at least A times and at most B times</strong>.</p>
<pre class="syntaxbox">bold smaller{1,3}</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold smaller</code></li>
<li><code>bold smaller smaller</code></li>
<li><code>bold smaller smaller smaller</code></li>
</ul>
<p>But not:</p>
<ul>
<li><code>bold</code>, as <code>smaller</code> must appear at least one time.</li>
<li><code>bold smaller smaller smaller smaller</code>, as <code>smaller</code> must appear at most three times.</li>
<li><code>smaller</code>, as <code>bold</code> is juxtaposed and must appear before any <code>smaller</code> keyword</li>
</ul>
<h3 id="Hash_mark_()">Hash mark (<code>#</code>)</h3>
<p>The <em>hash mark multiplier</em> indicates that the entity may be repeated one or more times (for example, the plus multiplier), but each occurrence is separated by a comma (',').</p>
<pre class="syntaxbox">bold smaller#</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold smaller</code></li>
<li><code>bold smaller, smaller</code></li>
<li><code>bold smaller, smaller, smaller</code>, and so on.</li>
</ul>
<p>But not:</p>
<ul>
<li><code>bold</code>, as <code>smaller</code> must appear at least one time.</li>
<li><code>bold smaller smaller smaller</code>, as the different occurrence of <code>smaller</code> must be separated by commas.</li>
<li><code>smaller</code>, as <code>bold</code> is juxtaposed and must appear before any <code>smaller</code> keyword.</li>
</ul>
<h3 id="Exclamation_point_(!)">Exclamation point (<code>!</code>)</h3>
<p>The <em>exclamation point multiplier</em> after a group indicates that the group is required, and must produce at least one value; even if the grammar of the items within the group would otherwise allow the entire contents to be omitted, at least one component value must not be omitted.</p>
<pre class="syntaxbox">[ bold? smaller? ]!
</pre>
<p>This example matches the following values:</p>
<ul>
<li><code>bold</code></li>
<li><code>smaller</code></li>
<li><code>bold smaller</code></li>
</ul>
<p>But not:</p>
<ul>
<li>neither <code>bold</code> nor <code>smaller</code>, as one of them must appear.</li>
<li><code>smaller bold</code>, as <code>bold</code> is juxtaposed and must appear before the <code>smaller</code> keyword.</li>
<li><code>bold smaller bold</code>, as <code>bold</code> and <code>smaller</code> may only appear once.</li>
</ul>
<h2 id="Summary">Summary</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Sign</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Example</th>
</tr>
</thead>
<tbody>
<tr>
<th colspan="4">Combinators</th>
</tr>
<tr>
<td> </td>
<td>Juxtaposition</td>
<td>Components are mandatory and should appear in that order</td>
<td><code>solid <length></code></td>
</tr>
<tr>
<td><code>&&</code></td>
<td>Double ampersand</td>
<td>Components are mandatory but may appear in any order</td>
<td><code><length> && <string></code></td>
</tr>
<tr>
<td><code>||</code></td>
<td>Double bar</td>
<td>At least one of the components must be present, and they may appear in any order.</td>
<td><code><'border-image-outset'> || <'border-image-slice'></code></td>
</tr>
<tr>
<td><code>|</code></td>
<td>Single bar</td>
<td>Exactly one of the components must be present</td>
<td><code>smaller | small | normal | big | bigger</code></td>
</tr>
<tr>
<td><code>[ ]</code></td>
<td>Brackets</td>
<td>Group components to bypass precedence rules</td>
<td><code>bold [ thin && <length> ]</code></td>
</tr>
<tr>
<th colspan="4">Multipliers</th>
</tr>
<tr>
<td> </td>
<td>No multiplier</td>
<td>Exactly 1 times</td>
<td><code>solid</code></td>
</tr>
<tr>
<td><code>*</code></td>
<td>Asterisk</td>
<td>0 or more times</td>
<td><code>bold smaller*</code></td>
</tr>
<tr>
<td><code>+</code></td>
<td>Plus sign</td>
<td>1 or more times</td>
<td><code>bold smaller+</code></td>
</tr>
<tr>
<td><code>?</code></td>
<td>Question mark</td>
<td>0 or 1 time (that is <em>optional)</em></td>
<td><code>bold smaller?</code></td>
</tr>
<tr>
<td><code>{A,B}</code></td>
<td>Curly braces</td>
<td>At least <code>A</code> times, at most <code>B</code> times</td>
<td><code>bold smaller{1,3}</code></td>
</tr>
<tr>
<td><code>#</code></td>
<td>Hash mark</td>
<td>1 or more times, but each occurrence separated by a comma ('<code>,</code>')</td>
<td><code>bold smaller#</code></td>
</tr>
<tr>
<td><code>!</code></td>
<td>Exclamation point</td>
<td>Group must produce at least 1 value</td>
<td><code>[ bold? smaller? ]!</code></td>
</tr>
</tbody>
</table>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName("CSS3 Values", "#value-defs", "Value definition syntax")}}</td>
<td>{{Spec2("CSS3 Values")}}</td>
<td>Adds the hash mark multiplier.</td>
</tr>
<tr>
<td>{{SpecName("CSS2.1", "about.html#value-defs", "Value definition syntax")}}</td>
<td>{{Spec2("CSS2.1")}}</td>
<td>Adds the double ampersand combinator.</td>
</tr>
<tr>
<td>{{SpecName("CSS1", "#notation-for-property-values", "Value definition syntax")}}</td>
<td>{{Spec2("CSS1")}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="See_also">See also</h2>
<ul>
<li>{{CSS_key_concepts}}</li>
</ul>
|