EDIT : found out - see answer below for solution.
Background : I have two elements: h1
and span
. I am trying to put a h1
“Heading” element to the left of a container element and a span
“Category” element to the right of a container that I made with float: left
and :right
,
Problem . I want a dashed line to appear between the elements h1
and span
. If possible, I would like to use a pseudo-element for this, since it is purely aesthetic, so I am trying to get the h1:after
pseduo element to fill the remaining width of the container element between h1
and span
.

, HTML :
<header>
<h1>Title</h1>
<span class="category">Category</span>
</header>
CSS - :after
h1
, h1
span
:
header {
display: block;
background: cyan;
width: 80%;
margin: 0 auto;
}
h1 {
display: block;
float: left;
}
h1:after {
display: block;
float: left;
width: 100%;
border-bottom: 1px dotted black;
content: " ";
}
span {
display: block;
float: right;
background: green;
}