I have a paragraph that contains text, possibly a span element, as well as some pseudo-content using the :before and :after selectors:
<p>Regular text with no span</p>
<p>Extra content with a <span>span</span></p>
My goal is to position the pseudo-content at the start and end of each paragraph like so:
« Regular text with no span »
« Extra content with a [span] »
I attempted to achieve this using grid-template-columns, but I'm struggling due to the presence of the additional span element. Is there a better approach using flexbox instead?
Below is a code snippet for reference:
p {
display: grid;
width: 40em;
grid-template-columns: 2rem ? ? 2rem;
span {
border: thin solid #ccc;
padding: 0 0.25rem;
}
&:before {
content: "«";
}
&:after {
content: "»";
}
}
<p>Regular text with no span</p>
<p>Extra content with a <span>span</span></p>