.formula, .letters { margin-top: 2px; margin-bottom: 2px; color: black; padding: 0.5rem; padding-bottom: 1px; margin-bottom: 0.5rem; } .formula p:last-child, .letters p:last-child { padding-bottom: 0; } .formula { background: lightblue; } .letters { background: lightyellow; }