Understanding display: run-in in CSS
display: run-in is a CSS display value intended to make an element behave like a block or inline element depending on its context. If followed by a block-level element, the run-in element behaves as inline; otherwise, it behaves as a block.
A run-in element can appear at the beginning of the following block element's content, effectively 'running into' it.
It can be styled like a block or inline element depending on its surrounding elements.
It is intended to reduce the need for extra markup for headings or introductory text.
Despite its intended behavior, display: run-in is rarely used because support across browsers is inconsistent. Most modern browsers do not reliably implement it, and its behavior can be confusing.
In this example, the <h2> is supposed to run into the paragraph, making the heading appear inline with the first line of text. However, many browsers will render it as a block, ignoring the run-in behavior.
Avoid relying on display: run-in due to poor and inconsistent browser support.
Use standard block or inline elements combined with CSS styling (e.g., inline headings or floated elements) for predictable layouts.
Consider using Flexbox or Grid for complex heading/text arrangements instead.
You're building a blog post component where the first heading should run into the first paragraph on wide screens but stack on mobile. You try display: run-in on the heading. What actually happens in Chrome vs Firefox today?
A teammate used display: run-in on a label before an input. The label disappears in Safari. How would you debug this and what fallback would you use?
We have a design where article meta (date, author) should inline with the first paragraph on desktop but be separate on mobile. The previous dev used display: run-in on the meta container. It works in Chrome but breaks in Firefox. Walk me through how you'd fix this without changing the HTML structure.
You're reviewing a PR that uses display: run-in for a 'kicker' headline that should merge with the following h1. The reviewer flags browser support. What alternatives would you propose and how do you decide?
Our design system has a 'run-in heading' pattern used across 50+ components. Browser support for display: run-in is flaky and the spec is deprecated. How would you refactor this pattern to be reliable, maintainable, and not break existing pages?
A new designer wants 'run-in' behavior for a complex marketing component with dynamic content. The component must work in IE11 (legacy) and modern browsers. You can't change the CMS output HTML. How do you implement this robustly?
We're migrating a 10-year-old codebase off display: run-in because it's causing layout shifts in Chrome 100+. The pattern appears in 200+ templates across 5 teams. How do you plan the migration, coordinate with teams, and prevent regressions?
The design org wants to standardize 'run-in' as a first-class pattern in our design system. Given the CSS spec history and browser reality, do you build a custom solution, use a polyfill, or push back? How do you justify the decision to leadership?