I am facing a minor issue with positioning a background image on a block element that comes after a floating element.
When I float an image to the left, followed by an H1
, the H1
flows behind the image, but its actual title appears next to the image due to the floating behavior.
The problem arises because the background-image on the H1
needs to align to the left, making it appear behind the img
.
For example:
(I added a second title with clear: left
property to demonstrate desired appearance).
One potential solution could be setting the left-margin of the title to slightly more than the width of the floating image, but this requires knowing the width in advance.
Another option is inserting the title's icon within an element inside the h1
, but this may not align with semantic correctness.
Is there a better CSS-only approach that avoids the need for extra elements?