/* a 'declaration' */
width: 500px;
width
: 500px;
text-wrap:
pretty
;
width:
500px
;
content-box
modelborder-box
modelinline-size:
500px
;
width
we care about exactly,inline-size:
45em
;
width:
min-content
;
width:
max-content
;
width:
100%
;
width:
90vw
;
width:
80cqi
;
width:
min(45em, 100%)
;
Graphic design of unknown content with unknown collaborators, on an infinite and unknowable canvas, across operating systems, interfaces, languages, and writing modes…
— me
There are too many variables to consider. The point of CSS is to make it so you don’t have to worry about them all.
— Keith J Grant
width:
auto
;
The fact we can control a paper page is really a limitation of that medium.
— John Allsopp, A Dao of Web Design
It takes craft to set up the circumstances that are simple and yet contain the ambiguities and the incongruity of human experience.
— Anne Bogart
500px
wide)16px
!= 1em
1em
sometimes gives the same result as 16px
flex
!= grid
Mostly based on formatting contexts
display
properties…demo:
span
with text & outlinewidth
height
display: block
, then display: list-item
display
of the element itself…body { display: flex; }
display: block
etcwidth
to be largefloat
body
display
valuedisplay
is a Shorthand
primarily inside and outside modes
display
creates
Formatting Context
fixed
)CSS takes a source document organized as a tree of elements… and text nodes… and renders it onto a canvas such as your screen.
The document canvas is the infinite surface over which the document is rendered.
width
/height
writing mode
[demo link]inline
axis is not always the width
height
insteaddirection
[demo link]width
-> inline-size
height
-> block-size
top
-> block-start
bottom
-> block-end
left
-> inline-start
right
-> inline-end
margin-right
-> margin-inline-end
margin-right
with margin-inline-end
margin-block
, padding-inline
, border-block
input {
margin-inline-end: 1em;
margin-left: 0;
}
…A tree of elements… and text nodes…
display
property
Box Generation Values
display
propertydisplay: none
Removes Box Tree
display: contents
Removes Box
div
s when doing layoutdisplay: list-item
Adds Marker Box
list-item
display::marker
boxDisplay:none;
(head/style) removes box & subtreeDisplay:contents;
(figure?) removes boxDisplay:list-item;
(li) generates a second ::marker
boxList-style-position
moves ::marker
in or out of primary boxdisplay
property
Outer Display Values
inline
or block
line-height
(initial normal
from font metrics)inline-size
block-size
block-size
inline-size
look up to parents…
Including %
and other ‘relative’ units
min-content
|max-content
| fit-content
box-sizing
property…
Selects Box Edge for Sizing
* { box-sizing: border-box; }
/* ::before, ::after {
box-sizing: border-box;
} */
content-box
box-sizing: border-box
on all elementsdisplay
…
Often Ignored
grid
inline
or block
, just a ‘grid item’inline
element in a block context can be ‘blockified’display
…
Flex, Grid, Table-*, Flow
block
➡️ block flow
inline
➡️ inline flow
\
grid
➡️ block grid
flex
➡️ block flex
table
➡️ block table
block
outer valueoverflow: hidden;
“A mini layout in your layout”…
overflow: hidden
inline-block
inline-flex
, inline-grid
, inline-block
block
» block flow
flow-root
» block flow-root
inline
» inline flow
flex
» block flex
grid
» block grid
list-item
» block flow list-item
inline-block
» inline flow-root
inline-flex
» inline flex
inline-grid
» inline grid
display
, position
, and float
Parent context can override
inline
& inline-*
➡️ block
& *
clamp(
min-content
size,
stretch-fit
size,
max-content
size)
overflow-x
/-y
| overflow-inline
/-block
Acts like auto
when single-axis
padding-box
edgepadding-box
+ overflow-clip-margin
edge(usually auto…)
clip
| ellipsis
break-word
| anywhere
[demo] change to use intrinsic sizes