There are numerous methods to achieve this, but one simple approach is to create an accent element and position it within the container. Utilizing a modern CSS technique like display:grid;
for the container can result in cleaner code structure.
In the grid layout, columns can overlap (with additional borders for clarity) while keeping the content's styling separate from the grid structure.
:root {
--main-accent-color: #ffdddd;
}
.grid-container {
display: grid;
grid-template-columns: 2rem 10rem 1fr;
grid-template-rows: repeat(2, 1fr);
border: 1px dotted orange;
}
.grid-container>* {
border: solid 1px red;
}
.title {
font-style: italic;
font-size: 1.5rem;
}
.title-accent {
background-color: var(--main-accent-color);
font-size: 0.75rem;
height: 1rem;
}
.one {
grid-column: 1 / 3;
grid-row: 1 / 3;
}
.two {
grid-column: 2 / 2;
grid-row: 2 / 3;
z-index: -1;
}
<div class="titleWrapper grid-container">
<h2 class="title one">About Me</h2>
<div class="title-accent two"> </div>
</div>
For positioning purposes:
:root {
--main-accent-color: #ffdddd;
}
.title {
font-style: italic;
border: solid 1px blue;
margin-bottom: 0;
}
.titleWrapper .title-accent {
display: absolute;
margin-top: -0.25rem;
margin-left: 2rem;
border-top: 20px solid;
border-top-color: var(--main-accent-color);
width: 10rem;
}
<div class="titleWrapper">
<h2 class="title">About Me</h2>
<div class="title-accent"></div>
</div>