h2 {
	/* Just to see things better. */
	background-color: hsla(200, 100%, 50%, 33%);
}

.precise:before,
.precise:after {
	content: ''; /* Empty. */
	display: block;
	visibility: hidden;
}

.precise:before { margin-top: var(--inset--top); }
.precise:after { margin-bottom: var(--inset--bottom); }

.precise {
	--inset--top:    -0.2em; /* Font-dependent! */
	--inset--bottom: -0.23em;
	--inset--left:   -0.07em;
	--inset--right:  -0.06em;

	display: flow-root; /* Cinch the height. */
	margin-left: var(--inset--left);
	margin-right: var(--inset--right);
	width: fit-content; /* Cinch the width. */
}
body {
	--base: 20px;

	display: grid;
	font-family: 'Helvetica', sans-serif;
	gap: var(--base);
	padding: var(--base);
}

section { background-color: gold; }

h2 { font-size: calc(var(--base) * 3); }
<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link href="/assets/styles/reset.css" rel="stylesheet">
		<link href="setup.css" rel="stylesheet">
		<link href="style.css" rel="stylesheet">
	</head>
	<body>
		<section>
			<h2>Line/<wbr>bounding box</h2>
		</section>
		<section>
			<h2 class="precise">Much better!</h2>
		</section>
	</body>
</html>