I've been attempting to display a <p>
and an <h4>
element side by side within a card.
I have experimented with the following:
.where,
.location {
display: inline-block;
color: #acdd1b;
font-size: 15px;
font-weight: 150px;
}
.when,
.dates {
display: inline;
color: #ddd01b;
font-size: 15px;
}
<p class="where">Where:</p>
<h4 class="location">Gili Air - Lombok, Indonesia</h4>
<p class="dates">When:</p>
<p class="dates">01-01-'24 - 01-03-'24</p>
This approach did not yield the desired outcome. The elements are still appearing on separate lines, albeit with less spacing due to using inline-block.
I also attempted placing them in a
<div class="line">
, as suggested in previous posts. Setting the CSS to .line {display: flex; align-items: center;}
resulted in success, but the layout looked unattractive as the heading was positioned higher than the paragraph.
Is there a solution to this issue? Perhaps another method besides styling the .line
element to manually adjust the position of the heading tag?