-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathvisudet.src
More file actions
981 lines (814 loc) · 40.4 KB
/
visudet.src
File metadata and controls
981 lines (814 loc) · 40.4 KB
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<!-- $Id: visudet.src,v 2.41 1998-05-03 16:12:05 ijacobs Exp $ -->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>Visual formatting model details</TITLE>
</HEAD>
<BODY>
<H1 align="center">Visual formatting model details</H1>
<H2><a name="containing-block-details">Definition of "containing
block"</a></H2>
<p>The position and size of an element's box(es) are sometimes
computed relative to a certain rectangle, called the <dfn><span
class="index-def" title="containing block">containing
block</span></dfn> of the element. The containing block of an element
is defined as follows:</p>
<ol>
<li>The containing block in which the <a href="conform.html#root">root
element</a> lives (called the initial containing block)
is chosen by the UA.
<li>For other elements, unless the element is absolutely positioned,
the containing block is formed by the content edge of the youngest
block-level ancestor box.
<li>If the element is absolutely positioned (i.e., the <span
class="propinst-position">'position'</span> property of the element is
either 'fixed' or 'absolute'), the containing block is established by
the youngest ancestor with a <span
class="propinst-position">'position'</span> other than 'static', in
the following way:
<ol>
<li>In the case that the ancestor is block-level, the containing block
is formed by the <a href="box.html#padding-edge">padding edge</a> of
the ancestor.
<li>In the case that the ancestor is inline-level, the containing
block depends on the <span
class="propinst-direction">'direction'</span> property of the
ancestor:
<ol>
<li>If the <span class="propinst-direction">'direction'</span> is 'ltr', the top and left of the containing
block are the top and left content edges of the first box generated by
the ancestor, and the bottom and right are the bottom and right
content edges of the last box of the ancestor.
<li>If the <span class="propinst-direction">'direction'</span> is 'rtl', the top and right are the top and
right edges of the first box of the ancestor, and the bottom and left
are the bottom and left content edges of the ancestor.
</ol>
</ol>
<p>If there is no such ancestor, the content edge of the root element's
box establishes the containing block.
</ol>
<div class="example">
<P>With no positioning, the containing blocks (C.B.) in the
following document:</p>
<PRE class="html-example">
<HTML>
<HEAD>
<TITLE>Illustration of containing blocks</TITLE>
</HEAD>
<BODY id="body">
<DIV id="div1">
<P id="p1">This is text in the first paragraph...</P>
<P id="p2">This is text <EM id="em1"> in the
<STRONG id="strong1">second</STRONG> paragraph.</EM></P>
</DIV>
</BODY>
</HTML>
</PRE>
<P>are established as follows:</P>
<table border>
<tr><th align="center">For box generated by
<td align="center"><strong>C.B. is
established by</strong></tr>
<tr><td align="center">body<td align="center">initial C.B. (UA-dependent)</tr>
<tr><td align="center">div1<td align="center">body</tr>
<tr><td align="center">p1<td align="center">div1</tr>
<tr><td align="center">p2<td align="center">div1</tr>
<tr><td align="center">em1<td align="center">p2</tr>
<tr><td align="center">strong1<td align="center">p2</tr>
</table>
<P>If we position "div1":</p>
<PRE class="example">
#div1 { position: absolute; left: 50px; top: 50px }
</PRE>
<P>its containing block is no longer "body"; it becomes
the initial containing block (since there are no
other positioned ancestor boxes).
<P>If we position "em1" as well:</p>
<PRE class="example">
#div1 { position: absolute; left: 50px; top: 50px }
#em1 { position: absolute; left: 100px; top: 100px }
</PRE>
<P>the table of containing blocks becomes:</p>
<table border>
<tr><th align="center">For box generated by
<td align="center"><strong>C.B. is
established by</strong></tr>
<tr><td align="center">body<td align="center">initial C.B.</tr>
<tr><td align="center">div1<td align="center">initial C.B.</tr>
<tr><td align="center">p1<td align="center">div1</tr>
<tr><td align="center">p2<td align="center">div1</tr>
<tr><td align="center">em1<td align="center">div1</tr>
<tr><td align="center">strong1<td align="center">p2</tr>
</table>
<P>By positioning "em1", its containing block becomes
the nearest positioned ancestor box (i.e., that generated
by "div1").
</div>
<h2><a name="the-width-property">Content width</a>: the <span
class="propinst-width">'width'</span> property</H2>
<!-- #include src=properties/width.srb -->
<P> This property specifies the <a
href="box.html#content-width">content width</a> of boxes generated by
block-level and <a href="conform.html#replaced-element">replaced</a> elements.
<P>This property does not apply to non-replaced <a
href="visuren.html#inline-level">inline-level</a> elements. The width
of a non-replaced inline element's boxes is that of the rendered
content within them (<em>before</em> any relative offset of
children). Recall that inline boxes flow into <a
href="visuren.html#line-box">line boxes</a>. The width of line boxes
is given by the their <a
href="visuren.html#containing-block">containing block</a>, but may be
shorted by the presence of <a href="visuren.html#floats">floats</a>.
<P>The width of a replaced element's box is <a
href="conform.html#intrinsic">intrinsic</a> and may be scaled by the
user agent if the value of this property is different than 'auto'.
<P>Values have the following meanings:</P>
<dl>
<dt><span class="index-inst" title="<length>"><span class="value-inst-length"><strong><length></strong></span></span>
<dd>Specifies a fixed width.
<dt><span class="index-inst" title="<percentage>"><span class="value-inst-percentage"><strong><percentage></strong></span></span>
<dd>Specifies a percentage width. The percentage is calculated
with respect to the width of the generated box's
<a href="visuren.html#containing-block">containing block</a>.
<dt><strong>auto</strong>
<dd>The width depends on the values of other properties.
See the sections below.
</dl>
<P>Negative values for <span class="propinst-width">'width'</span> are
illegal.
<div class="example"><P>
For example, the following rule fixes the content width of paragraphs
at 100 pixels:</p>
<PRE>
P { width: 100px }
</PRE>
</div>
<H2><a name="Computing_widths_and_margins">Computing widths and
margins</a></H2>
<p>The computed values of an element's <span
class="propinst-width">'width'</span>, <span
class="propinst-margin-left">'margin-left'</span>, <span
class="propinst-margin-right">'margin-right'</span>, <span
class="propinst-left">'left'</span> and <span
class="propinst-right">'right'</span> properties depend on the type of
box generated and on each other. In principle, the computed values are the same
as the specified values, with 'auto' replaced by some suitable value,
but there are exceptions. The following situations need to be
distinguished:</p>
<ol>
<li>inline, non-replaced elements
<li>inline, replaced elements
<li>block-level, non-replaced elements in normal flow
<li>block-level, replaced elements in normal flow
<li>floating, non-replaced elements
<li>floating, replaced elements
<li>absolutely positioned, non-replaced elements
<li>absolutely positioned, replaced elements
</ol>
<h3>Inline, non-replaced elements</h3>
<p>The <span class="propinst-width">'width'</span> property does not
apply. A specified value of 'auto' for <span
class="propinst-left">'left'</span>, <span
class="propinst-right">'right'</span>, <span
class="propinst-margin-left">'margin-left'</span> or <span
class="propinst-margin-right">'margin-right'</span> becomes a computed
value of '0'.
<h3>Inline, replaced elements</h3>
<p>A specified value of 'auto' for <span
class="propinst-left">'left'</span>, <span
class="propinst-right">'right'</span>, <span
class="propinst-margin-left">'margin-left'</span> or <span
class="propinst-margin-right">'margin-right'</span> becomes a computed
value of '0'. A specified value of 'auto' for <span
class="propinst-width">'width'</span> gives the element's <a
href="conform.html#intrinsic">intrinsic</a> width as the computed value.
<h3>Block-level, non-replaced elements in normal flow</h3>
<p>If <span class="propinst-left">'left'</span> or <span
class="propinst-right">'right'</span> are given as 'auto', their
computed value is 0. The following <a
name="width-constraints">constraints</a> must hold between the other
properties:</p>
<blockquote>
<p><span class="propinst-margin-left">'margin-left'</span> + <span
class="propinst-border-left-width">'border-left-width'</span> + <span
class="propinst-padding-left">'padding-left'</span> + <span
class="propinst-width">'width'</span> + <span
class="propinst-padding-right">'padding-right'</span> + <span
class="propinst-border-right-width">'border-right-width'</span> +
<span class="propinst-margin-right">'margin-right'</span> = width of <a
href="#containing-block-details">containing block</a>
</blockquote>
<p>(If the border style is 'none', use '0' as the border width.) If
all of the above have a specified value other than 'auto', the values
are said to be "over-constrained" and one of the computed values will
have to be different from its specified value. If the <span
class="propinst-direction">'direction'</span>
property has the value 'ltr', the specified value of <span
class="propinst-margin-right">'margin-right'</span> is ignored and the
value is computed so as to make the equality true. If the value of
<span class="propinst-direction">'direction'</span> is 'ltr', this
happens to <span class="propinst-margin-left">'margin-left'</span> instead.
<p>If there is exactly one value specified as 'auto', its computed
value follows from the equality.
<p>If <span class="propinst-width">'width'</span> is set to 'auto',
any other 'auto' values become '0' and <span
class="propinst-width">'width'</span> follows from the resulting
equality.
<p>If both <span class="propinst-margin-left">'margin-left'</span> and
<span class="propinst-margin-right">'margin-right'</span> are 'auto',
their computed values are equal.
<h3>Block-level, replaced elements in normal flow</h3>
<p>If <span class="propinst-left">'left'</span> or <span
class="propinst-right">'right'</span> are 'auto', their computed value
is 0. If <span class="propinst-width">'width'</span> is specified as
'auto', its value is the element's <a
href="conform.html#intrinsic">intrinsic</a> width. If one of the margins is
'auto', its computed value is given by the <a
href="#width-constraints">constraints</a> above. Furthermore, if both
margins are 'auto', their computed values are equal.
<h3>Floating, non-replaced elements</h3>
<p>If <span class="propinst-left">'left'</span>, <span
class="propinst-right">'right'</span>, <span
class="propinst-width">'width'</span>, <span
class="propinst-margin-left">'margin-left'</span>, or <span
class="propinst-margin-right">'margin-right'</span> are specified as
'auto', their computed value is '0'.
<h3>Floating, replaced elements</h3>
<p>If <span class="propinst-left">'left'</span>, <span
class="propinst-right">'right'</span>, <span
class="propinst-margin-left">'margin-left'</span> or <span
class="propinst-margin-right">'margin-right'</span> are specified as
'auto', their computed value is '0'. If 'width' is 'auto', its value
is the element's <a href="conform.html#intrinsic">intrinsic</a> width.
<h3><a name="abs-non-replaced-width">Absolutely positioned, non-replaced elements</a></h3>
<p>The constraint that determines the computed values for these
elements is:
<blockquote>
<p><span class="propinst-left">'left'</span> + <span
class="propinst-margin-left">'margin-left'</span> + <span
class="propinst-border-left-width">'border-left-width'</span> + <span
class="propinst-padding-left">'padding-left'</span> + <span
class="propinst-width">'width'</span> + <span
class="propinst-padding-right">'padding-right'</span> + <span
class="propinst-border-right-width">'border-right-width'</span> +
<span class="propinst-margin-right">'margin-right'</span> + <span
class="propinst-right">'right'</span> = width of <a
href="#containing-block-details">containing block</a>
</blockquote>
<p>(If the border style is 'none', use '0' as the border width.) The
solution to this constraint is reached through a number of
substitutions in the following order:</p>
<ol>
<li>If <span class="propinst-left">'left'</span>
has the value 'auto' while <span
class="propinst-direction">'direction'</span> is 'ltr', replace
'auto' with the
distance from the left edge of the containing block to the left margin
edge of a hypothetical box that would have been the first box of the
element if its <span class="propinst-position">'position'</span>
property had been 'static'. (But rather than actually computing that
box, UAs are free to make a guess at its probable position.) The value
is negative if the hypothetical box is to the left of the
containing block.
<li>If <span class="propinst-right">'right'</span> has the
value 'auto' while
<span class="propinst-direction">'direction'</span> is 'rtl',
replace 'auto' with
the distance from the right edge of the containing block to
the right margin edge of the same hypothetical box as above. The value
is positive if the hypothetical box is to the left of the containing
block's edge.
<li>If <span class="propinst-width">'width'</span> is 'auto',
replace any remaining 'auto' for <span class="propinst-left">'left'</span>
or <span class="propinst-right">'right'</span> with '0'.
<li>If <span class="propinst-left">'left'</span>, <span
class="propinst-right">'right'</span> or <span
class="propinst-width">'width'</span> are (still) 'auto', replace any
'auto' on <span class="propinst-margin-left">'margin-left'</span> or
<span class="propinst-margin-right">'margin-right'</span> with '0'.
<li>If at this point both <span
class="propinst-margin-left">'margin-left'</span> and <span
class="propinst-margin-right">'margin-right'</span> are still 'auto',
solve the equation under the extra constraint that the two margins
must get equal values.
<li>If at this point there is only one 'auto' left, solve the equation
for that value.
<li>If at this point the values are over-constrained, ignore the value
for either <span class="propinst-left">'left'</span> (in case <span
class="propinst-direction">'direction'</span> is 'rtl') or <span
class="propinst-right">'right'</span> (in case <span
class="propinst-direction">'direction'</span> is 'ltr')
and solve for that value.
</ol>
<h3>Absolutely positioned, replaced elements</h3>
<P>This situation is similar to the previous one, except that the
element has an <a href="conform.html#intrinsic">intrinsic</a> width. The
sequence of substitutions is now:</p>
<ol>
<li>If <span class="propinst-width">'width'</span> is 'auto',
substitute the element's <a
href="conform.html#intrinsic">intrinsic</a> width.
<li>If <span class="propinst-left">'left'</span>
has the value 'auto' while <span
class="propinst-direction">'direction'</span> is 'ltr', replace
'auto' with the
distance from the left edge of the containing block to the left margin
edge of a hypothetical box that would have been the first box of the
element if its <span class="propinst-position">'position'</span>
property had been 'static'. (But rather than actually computing that
box, UAs are free to make a guess at its probable position.) The value
is negative if the hypothetical box is to the left of the
containing block.
<li>If <span class="propinst-right">'right'</span> has the
value 'auto' while
<span class="propinst-direction">'direction'</span> is 'rtl',
replace 'auto' with
the distance from the right edge of the containing block to
the right margin edge of the same hypothetical box as above. The value
is positive if the hypothetical box is to the left of the containing
block's edge.
<li>If <span class="propinst-left">'left'</span> or <span
class="propinst-right">'right'</span> are 'auto', replace any 'auto'
on <span class="propinst-margin-left">'margin-left'</span> or <span
class="propinst-margin-right">'margin-right'</span> with '0'.
<li>If at this point both <span
class="propinst-margin-left">'margin-left'</span> and <span
class="propinst-margin-right">'margin-right'</span> are still 'auto',
solve the equation under the extra constraint that the two margins
must get equal values.
<li>If at this point there is only one 'auto' left, solve the equation
for that value.
<li>If at this point the values are over-constrained, ignore the value
for either <span class="propinst-left">'left'</span> (in case <span
class="propinst-direction">'direction'</span> is 'rtl') or <span
class="propinst-right">'right'</span> (in case <span
class="propinst-direction">'direction'</span> is 'ltr') and solve for
that value.
</ol>
<H2><a name="min-max-widths">Minimum and maximum widths</a>: <span
class="propinst-min-width">'min-width'</span> and <span
class="propinst-max-width">'max-width'</span></h2>
<!-- #include src=properties/min-width.srb -->
<!-- #include src=properties/max-width.srb -->
<P>These two properties allow authors to constrain box widths to a
certain range. Values have the following meanings:</p>
<dl>
<dt><span class="index-inst" title="<length>"><span class="value-inst-length"><strong><length></strong></span></span>
<dd>Specifies a fixed minimum or maximum computed width.
<dt><span class="index-inst" title="<percentage>"><span class="value-inst-percentage"><strong><percentage></strong></span></span>
<dd>Specifies a percentage for determining the computed value.
The percentage is calculated
with respect
to the width of the
generated box's
<a href="visuren.html#containing-block">containing block</a>.
<dt><strong>none</strong>
<dd>(Only on <span class="propinst-max-width">'max-width'</span>) No
limit on the width of the box.
</dl>
<P>The following algorithm describes how the two properties influence
the <a href="cascade.html#computed-value">computed value</a>
of the <span class="propinst-width">'width'</span> property:</p>
<OL>
<LI>The width is computed (without
<span class="propinst-min-width">'min-width'</span> and <span
class="propinst-max-width">'max-width'</span>) following the rules
under <a href="#Computing_widths_and_margins">"Computing widths and
margins"</a> above.
<LI>If the computed value of <span
class="propinst-min-width">'min-width'</span> is greater than the
value of <span class="propinst-max-width">'max-width'</span>, <span
class="propinst-max-width">'max-width'</span> is set to the
value of <span class="propinst-min-width">'min-width'</span>.
<LI>If the computed width is greater than <span
class="propinst-max-width">'max-width'</span>, the rules <a
href="#Computing_widths_and_margins">above</a> are applied again, but
this time using the value of <span class="propinst-max-width">'max-width'</span> as the specified value for
<span class="propinst-width">'width'</span>.
<LI>If the computed width is smaller than <span
class="propinst-min-width">'min-width'</span>, the rules <a
href="#Computing_widths_and_margins">above</a> are applied again, but
this time using the value of <span class="propinst-min-width">'min-width'</span> as the specified value for
<span class="propinst-width">'width'</span>.
</OL>
<P>The user agent may define a non-negative minimum value for the
<span class="propinst-min-width">'min-width'</span> property, which
may vary from element to element and even depend on other
properties. If <span class="propinst-min-width">'min-width'</span>
goes below this limit, either because it was set explicitly, or
because it was 'auto' and the rules below would make it too small, the
user agent may use the minimum value as the computed value.
<h2><a name="the-height-property">Content height</a>: the <span
class="propinst-height">'height'</span> property</H2>
<!-- #include src=properties/height.srb -->
<P> This property specifies the <a
href="box.html#content-height">content height</a> of boxes generated
by block-level and <a href="conform.html#replaced-element">replaced</a> elements.
<P>This property does not apply to non-replaced <a
href="visuren.html#inline-level">inline-level</a> elements. The
height of a non-replaced inline element's boxes is given by the element's
(possibly inherited) <span
class="propinst-line-height">'line-height'</span> value.
<!--
<P>The height of a replaced element's box is <a
href="conform.html#intrinsic">intrinsic</a> and may be scaled by the user
agent if the value of this property is different than 'auto'.
-->
<P>Values have the following meanings:</P>
<dl>
<dt><span class="index-inst" title="<length>"><span class="value-inst-length"><strong><length></strong></span></span>
<dd>Specifies a fixed height.
<dt><span class="index-inst" title="<percentage>"><span class="value-inst-percentage"><strong><percentage></strong></span></span>
<dd>Specifies a percentage height. The percentage is calculated
with respect to the height of the
generated box's <a href="visuren.html#containing-block">containing
block</a>. If the height of the containing block is not
specified explicitly (i.e., it depends on content height), the
value is interpreted like 'auto'.
<dt><strong>auto</strong>
<dd>The height depends on the values of other properties.
See the prose below.
</dl>
<P>Negative values for <span class="propinst-height">'height'</span>
are illegal.
<div class="example"><P>
For example, the following rule fixes the height of paragraphs
to 100 pixels:</p>
<PRE>
P { height: 100px }
</PRE>
<P>Paragraphs that require more than 100 pixels of height will
<a href="visufx.html#overflow">overflow</a> according
to the <span class="propinst-overflow">'overflow'</span> property.
</div>
<h2><a name="Computing_heights_and_margins">Computing heights and
margins</a></h2>
<p>For computing the values of <span class="propinst-top">'top'</span>, <span class="propinst-margin-top">'margin-top'</span>, <span class="propinst-height">'height'</span>,
<span class="propinst-margin-bottom">'margin-bottom'</span>, and <span class="propinst-bottom">'bottom'</span> a distinction must be made b
B6C
etween
various kinds of boxes:
<ol>
<li>inline, non-replaced elements
<li>inline, replaced elements
<li>block-level, non-replaced elements in normal flow
<li>block-level, replaced elements in normal flow
<li>floating, non-replaced elements
<li>floating, replaced elements
<li>absolutely positioned, non-replaced elements
<li>absolutely positioned, replaced elements
</ol>
<H3>Inline, non-replaced elements</H3>
<p>If <span class="propinst-top">'top'</span>, <span
class="propinst-bottom">'bottom'</span>, <span
class="propinst-margin-top">'margin-top'</span>, or <span
class="propinst-margin-bottom">'margin-bottom'</span> are 'auto',
their computed value is 0. The <span
class="propinst-height">'height'</span> property doesn't apply, but
the height of the box is given by the <span
class="propinst-line-height">'line-height'</span> property.
<H3>Inline, replaced elements
block-level, replaced elements in normal flow, and
floating, replaced elements</H3>
<p>If <span class="propinst-top">'top'</span>, <span
class="propinst-bottom">'bottom'</span>, <span
class="propinst-margin-top">'margin-top'</span>, or <span
class="propinst-margin-bottom">'margin-bottom'</span> are 'auto',
their computed value is 0. If <span
class="propinst-height">'height'</span> is 'auto', the computed value
is the <a href="conform.html#intrinsic">intrinsic</a> height.
<H3>Block-level, non-replaced elements in normal flow, and
floating, non-replaced elements</H3>
<p>If <span class="propinst-top">'top'</span>, <span class="propinst-bottom">'bottom'</span>, <span class="propinst-margin-top">'margin-top'</span>, or <span class="propinst-margin-bottom">'margin-bottom'</span> are 'auto',
their computed value is 0. If <span class="propinst-height">'height'</span> is 'auto', the height depends
on whether the element has any block-level children. If it only has
inline-level children, the height is from the top of the topmost line
box to the bottom of the bottommost line box. If it has block-level
children, it is the distance from the top border-edge of the topmost
block-level child box, to the bottom border-edge of the bottommost
block-level child box. Only children in the normal flow are taken into
account (i.e., floating boxes are ignored, as are absolutely
positioned ones, and relatively positioned boxes are considered
without their offset). Note that the child box may be an <a
href="visuren.html#anonymous-block-level">anonymous box.</a>
<H3><a name="abs-non-replaced-height">Absolutely positioned, non-replaced elements</a></H3>
<p>For absolutely positioned elements, the vertical dimensions must
satisfy this constraint:
<blockquote>
<p>'top' + 'margin-top' + 'border-top-width' + 'padding-top' +
'height' + 'padding-bottom' + 'border-bottom-width' + 'margin-bottom'
+ 'bottom' = height of containing block
</blockquote>
<p>(If the border style is 'none', use '0' as the border width.) The
solution to this constraint is reached through a number of
substitutions in the following order:
<ol>
<li>If <span class="propinst-top">'top'</span> has the value 'auto'
replace it with the distance from the top edge of the containing block
to the top margin edge of a hypothetical box that would have been the
first box of the element if its <span
class="propinst-position">'position'</span> property had been
'static'. (But rather than actually computing that box, UAs are free
to make a guess at its probable position.) The value is negative if
the hypothetical box is above the containing block.
<li>If both <span class="propinst-height">'height'</span> and <span
class="propinst-bottom">'bottom'</span> are 'auto', replace <span class="propinst-bottom">'bottom'</span>
with 0.
<li>If <span class="propinst-bottom">'bottom'</span> or <span
class="propinst-height">'height'</span> are (still) 'auto', replace
any 'auto' on <span class="propinst-margin-top">'margin-top'</span> or
<span class="propinst-margin-bottom">'margin-bottom'</span> with '0'.
<li>If at this point both <span
class="propinst-margin-top">'margin-top'</span> and <span
class="propinst-margin-bottom">'margin-bottom'</span> are still
'auto', solve the equation under the extra constraint that the two
margins must get equal values.
<li>If at this point there is only one 'auto' left, solve the equation
for that value.
<li>If at this point the values are over-constrained, ignore the value
for <span class="propinst-bottom">'bottom'</span> and solve for that
value.
</ol>
<H3>Absolutely positioned, replaced elements</H3>
<p>This situation is similar to the previous one, except that the
element has an <a href="conform.html#intrinsic">intrinsic</a> height. The
sequence of substitutions is now:
<ol>
<li>If <span class="propinst-height">'height'</span> is 'auto',
substitute the element's <a href="conform.html#intrinsic">intrinsic</a>
height.
<li>If <span class="propinst-top">'top'</span> has the value 'auto',
replace it with the distance from the top edge of the containing block
to the top margin edge of a hypothetical box that would have been the
first box of the element if its <span
class="propinst-position">'position'</span> property had been
'static'. (But rather than actually computing that box, UAs are free
to make a guess at its probable position.) The value is negative if
the hypothetical box is above the containing block.
<li>If <span class="propinst-bottom">'bottom'</span> is 'auto',
replace any 'auto' on <span
class="propinst-margin-top">'margin-top'</span> or <span
class="propinst-margin-bottom">'margin-bottom'</span> with '0'.
<li>If at this point both <span
class="propinst-margin-top">'margin-top'</span> and <span
class="propinst-margin-bottom">'margin-bottom'</span> are still
'auto', solve the equation under the extra constraint that the two
margins must get equal values.
<li>If at this point there is only one 'auto' left, solve the equation
for that value.
<li>If at this point the values are over-constrained, ignore the value
for <span class="propinst-bottom">'bottom'</span> and solve for that
value.
</ol>
<H2><a name="min-max-heights">Minimum and maximum heights</a>: <span
class="propinst-min-height">'min-height'</span> and <span
class="propinst-max-height">'max-height'</span></h2>
<P>It is sometimes useful to constrain the height of elements to a
certain range. Two properties offer this functionality:
<!-- #include src=properties/min-height.srb -->
<!-- #include src=properties/max-height.srb -->
<P>These two properties allow authors to constrain box heights to a
certain range. Values have the following meanings:</p>
<dl>
<dt><span class="index-inst" title="<length>"><span class="value-inst-length"><strong><length></strong></span></span>
<dd>Specifies a fixed minimum or maximum computed height.
<dt><span class="index-inst" title="<percentage>"><span class="value-inst-percentage"><strong><percentage></strong></span></span>
<dd>Specifies a percentage for determining the computed value.
The percentage is calculated with respect to the height of the
generated box's <a href="visuren.html#containing-block">containing block</a>.
If the height of the containing block is not
specified explicitly (i.e., it depends on content height), the
percentage value is interpreted like 'auto'.
<dt><strong>none</strong>
<dd>(Only on <span class="propinst-max-height">'max-height'</span>) No limit on the height of the box.
</dl>
<P>The following algorithm describes how the two properties influence
the <a href="cascade.html#computed-value">computed value</a>
of the <span class="propinst-height">'height'</span> property:</p>
<OL>
<LI>The height is computed (without <span
class="propinst-min-height">'min-height'</span> and <span
class="propinst-max-height">'max-height'</span>) following the rules
under <a href="#Computing_heights_and_margins">"Computing heights and
margins"</a> above.
<LI>If the computed value of <span
class="propinst-min-height">'min-height'</span> is greater than the
value of <span class="propinst-max-height">'max-height'</span>, <span
class="propinst-max-height">'max-height'</span> is set to the value of
<span class="propinst-min-height">'min-height'</span>.
<LI>If the computed height is greater than <span
class="propinst-max-height">'max-height'</span>, the rules <a
href="#Computing_heights_and_margins">above</a> are applied again, but
this time using the value of <span class="propinst-max-height">'max-height'</span> as the specified value for
<span class="propinst-height">'height'</span>.
<LI>If the computed height is smaller than <span
class="propinst-min-height">'min-height'</span>, the rules <a
href="#Computing_heights_and_margins">above</a> are applied again, but
this time using the value of <span class="propinst-min-height">'min-height'</span> as the specified value for
<span class="propinst-height">'height'</span>.
</OL>
<H2><a name="line-height">Line height calculations</a>: the <span
class="propinst-line-height">'line-height'</span> and <span
class="propinst-vertical-align">'vertical-align'</span>
properties</H2>
<P>As described in the section on <a
href="visuren.html#inline-formatting">inline formatting contexts</a>,
user agents flow inline boxes into a vertical stack of <a
href="visuren.html#line-box">line boxes</a>. The height of a line box
is determined as follows:</p>
<ol>
<li>The height of each inline box in the line box is calculated (see
<a href="#Computing_heights_and_margins">"Computing heights and
margins"</a> and the <span
class="propinst-line-height">'line-height'</span> property).
<li>The inline boxes are aligned vertically according
to their <span class="propinst-vertical-align">'vertical-align'</span>
property. <!-- If an element
has the values <span class="propinst-top">'top'</span> or <span class="propinst-bottom">'bottom'</span> for this property, only
the height of the generated boxes affects the line box
height calculation; the boxes cannot be aligned until the
line box has been fully constructed. -->
<li>The line box height is the distance between the uppermost
box top and the lowermost box bottom.
</ol>
<p>Empty inline elements generate empty inline boxes, but these boxes
still have margins, padding, borders and a line height, and thus
influence these calculations just like elements with content.
<P>Note that if all the boxes in the line box are aligned along their
bottoms, the line box will be exactly the height of the tallest box.
If, however, the boxes are aligned along a common baseline, the line
box top and bottom may not touch the top and bottom of the tallest
box.
<H3>Leading and half-leading</h3>
<P>Since the height of an inline box may be different from the font size
of text in the box (e.g., <span
class="propinst-line-height">'line-height'</span> > 1em), there may
be space above and below rendered glyphs. The difference between the
font size and the computed value of <span
class="propinst-line-height">'line-height'</span> is called the <span
class="index-def" title="leading"><EM>leading</EM></span>. Half the
leading is called the <span class="index-def"
title="half-leading"><EM>half-leading</EM></span>.
<P>User agents center glyphs vertically in an inline box, adding
half-leading on the top and bottom. For example, if a piece of text
is '12pt' high and the <span
class="propinst-line-height">'line-height'</span> value is '14pt',
2pts of extra space should be added: 1pt above and 1pt below the
letters. (This applies to empty boxes as well, as if the empty box
contained an infinitely narrow letter.)
<P>When the <span class="propinst-line-height">'line-height'</span>
value is less than the font size, the final inline box height will be
less than the font size and the rendered glyphs will "bleed" outside
the box. If such a box touches the edge of a line box, the rendered
glyphs will also "bleed" into the adjacent line box.
<P>Although margins, borders, and padding of non-replaced elements do
not enter into inline
box height calculation (and thus the line box calculation), they are
still rendered around inline boxes<!-- (except where boxes are split
across lines)-->. This means that if the height of a line box is shorter
than the <a href="box.html#outer-edge">outer edges</a> of the boxes it
contains, backgrounds and colors of padding and borders may "bleed"
into adjacent line boxes. However, in this case, some user agents may
use the line box to "clip" the border and padding areas (i.e., not
render them).
<!-- #include src=properties/line-height.srb -->
<p>If the property is set on a <a
href="visuren.html#block-level">block-level</a> element whose content
is composed of <a href="visuren.html#inline-level">inline-level</a>
elements, it specifies the <em>minimal</em> height of each
generated inline box.
<p>If the property is set on an <a
href="visuren.html#inline-level">inline-level</a> element, it
specifies the <em>exact</em> height of each box generated by the
element. (Except for inline <a
href="conform.html#replaced-element">replaced</a> elements, where the
height of the box is given by the <span
class="propinst-height">'height'</span> property.)
<P>Values for this property have the following meanings:</p>
<dl>
<dt><strong>normal</strong>
<dd>Tells user agents to set the <a
href="cascade.html#computed-value">
computed value</a> to a "reasonable"
value based on the font size of the element. The
value has the same meaning as <span class="index-inst" title="<number>"><span class="value-inst-number"><number></span></span>.
We recommend a computed value for 'normal' between 1.0 to 1.2.
<dt><span class="index-inst" title="<length>"><span
class="value-inst-length"><strong><length></strong></span></span>
<dd>The box height is set to this length. Negative values are illegal.
<dt><span class="index-inst" title="<number>"><span
class="value-inst-number"><strong><number></strong></span></span>
<dd>The
<a href="cascade.html#computed-value">
computed value</a> of the property is this number multiplied by the
element's font size. Negative values are illegal. However, the
number, not the <a href="cascade.html#computed-value">computed value</a>,
is inherited.
<dt><span class="index-inst" title="<percentage>"><span
class="value-inst-percentage"><strong><percentage></strong></span></span>
<dd>The <a href="cascade.html#computed-value">computed value</a> of the
property is this percentage multiplied by the element's
computed font size. Negative values are illegal.
</dl>
<div class="example"><P>
The three rules in the example below have the same resultant line height:
<PRE>
DIV { line-height: 1.2; font-size: 10pt } /* number */
DIV { line-height: 1.2em; font-size: 10pt } /* length */
DIV { line-height: 120%; font-size: 10pt } /* percentage */
</PRE>
</div>
<P>When an element contains text that is rendered in more than one
font, user agents should determine the <span
class="propinst-line-height">'line-height'</span> value according to
the largest font size. <!-- change this if font-size inheritance is
changed as per HWL's proposal -->
<P>Generally, when there is only one value of <span
class="propinst-line-height">'line-height'</span> for all inline
boxes in a paragraph (and no tall images), the above will ensure that
baselines of successive lines are exactly <span
class="propinst-line-height">'line-height'</span> apart. This is
important when columns of text in different fonts have to be aligned,
for example in a table.
<P>Note that replaced elements have a <span
class="propinst-font-size">'font-size'</span> and a <span
class="propinst-line-height">'line-height'</span> property, even if
they are not used directly to determine the height of the box. The
<span class="propinst-font-size">'font-size'</span> is, however, used
to define the 'em' and 'ex' units, and the 'line-height' has a role in
the <span class="propinst-vertical-align">'vertical-align'</span>
property.
<!-- #include src=properties/vertical-align.srb -->
<P>This property affects the vertical positioning inside a line box of
the boxes generated by an inline-level element. The following values
only have meaning with respect to a parent inline-level element, or to
a parent block-level element, if that element generates <a
hre
7C27
f="visuren.html#anonymous">anonymous inline boxes</a>; they have no
effect if no such parent exists.</P>
<div class="note"><P>
<em><strong>Note.</strong> Values of this property have
slightly different meanings in the context of tables.
Please consult the section on <a href="tables.html#height-layout">
table height algorithms</a> for details.
</em>
</div>
<DL>
<DT><strong>baseline</strong>
<DD>Align the baseline of the box with the baseline of
the parent box. If the box doesn't have a baseline,
align the bottom of the box with the parent's baseline.
<DT><strong>middle</strong>
<DD>Align the vertical midpoint of the box with the baseline
of the parent box plus half the x-height of the parent.
<DT><strong>sub</strong>
<DD>Lower the baseline of the box to the proper position for
subscripts of the parent's box. (This value has no effect on the
font size of the element's text.)
<DT><strong>super</strong>
<DD>Raise the baseline of the box to the proper position for
superscripts of the parent's box. (This value has no effect on the
font size of the element's text.)
<DT><strong>text-top</strong>
<DD>Align the top of the box with the top of the parent element's font.
<!-- What is several fonts are used? (text-bottom as well) -IJ -->
<DT><strong>text-bottom</strong>
<DD>Align the bottom of the box with the bottom of the parent
element's font.
<DT><span class="index-inst" title="<percentage>"><span
class="value-inst-percentage"><strong><percentage>
</strong></span></span>
<DD>Raise (positive value) or lower (negative value) the box
by this distance (a percentage of the <span
class="propinst-line-height">'line-height'</span> value).
The value '0%' means the same as 'baseline'.
<DT><span class="index-inst" title="<length>"><span
class="value-inst-length"><strong><length>
</strong></span></span>
<DD>Raise (positive value) or lower (negative value) the box
by this distance.
The value '0cm' means the same as 'baseline'.
</DL>
<P>The remaining values refer to the line box in which the
generated box appears:</p>
<DL>
<DT><strong>top</strong>
<DD>Align the top of the box with the top of the line box.
<DT><strong>bottom</strong>
<DD>Align the bottom of the box with the bottom of the line box.
</DL>
</BODY>
</HTML>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:nil
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:nil
sgml-indent-data:t
sgml-parent-document:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->