Inner and outer display types
Definition and purpose
Display has an outer role in the parent formatting context and an inner role for laying out contents. Thinking about these separately explains why inline-block can sit in text while containing sized content.
Sized inline badge
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style>#a, #b { display: inline-block; width: 70px; height: 28px; }</style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>Both badges have dimensions while participating inline.
Syntax and mental model
display: inline-block corresponds to inline flow-root; display: block corresponds to block flow. The outer keyword determines participation where applicable; the inner keyword governs descendants. Flex and grid are additional inner models studied later.
Two-keyword spelling
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> #a { display: inline flow-root; width: 90px; } #b { display: block flow; } </style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>The resolved values use equivalent legacy spellings.
Common mistakes
Do not interpret inline-block as ordinary inline sizing. It accepts explicit width and height. Computed display can serialize the familiar single keyword instead of the equivalent pair.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Block and inline layout. Next lesson: Block formatting contexts.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Inner and outer display types — knowledge check
Five questions on inner and outer display types.
What does outer display describe?
What does inner display describe?
Which pair corresponds to inline-block?
Which can take explicit width in ordinary inline flow?
Must computed display retain two-keyword syntax?