<div class="wrapper">
    <article class="flow">
      <h1>Next sibling selector - controlled with child combinator</h1>
      <figure class="callout">
          When we add a child combinator (<code>&gt;</code>), there’s no issue with
          recursion, which removes unpredictable behaviour in child elements.
      <div class="top box">
        <p>I have no margin because I am the first child.</p>
          I have <code>margin-top</code> because I am a <strong>next sibling</strong>.
          I have a <strong>bold</strong> <em>then an emphasised bit of text</em>,
          which because I put <code>inline-block</code> on my emphasised text, which
          is fine because we have a <strong>child combinator</strong>.
.top > * + * {
  margin-top: 1.5em;

em {
  display: inline-block;

/* Presentation styles */
.top p {
  border: 1px solid var(--color-primary);
  background: var(--color-light);
  padding: 1em;

/* Presentational styles */
.top > * + * {
  position: relative;

.top > * + *::before {
  content: "";
  width: 100%;
  height: 1.5em;
  background: #ff807b;
  position: absolute;
  bottom: 100%;
  left: 0;
  outline: 1px solid #9d0600;

External CSS

  1. https://codepen.io/web-dot-dev/pen/abpoXGZ.css

External JavaScript

This Pen doesn't use any external JavaScript resources.