JSFiddle - React, Tailwind, and code Playground

HTML

<!-- How to make .container.first surround the content and ends up looking similar to .container.second - Ideally you should only have to add CSS to .first to get it to wrap its children properly.-->

<div class="container first">
    <h1>Hello</h1>
    <h2>World</h2>
</div>

<div class="container second">
    <h1>Hello</h1>
    <h2>World</h2>
</div>

CSS

.container {
    background-color: #cccccc;
    padding: 1em;
    overflow:hidden;
}
h1, h2 {
    margin: 0
}


.first h1 {
    float: left;
}
.first h2 {
    float: right;
}


.second {
    margin-top: 100px;
}
.second h1 {
    text-align: left;
}
.second h2 {
    text-align: right;
    margin-top: -1.4em;
}