I want to stop text going over the yellow box, and go into line below it.
I assume this happens because the indent is bigger than the first word, but is there a trick to make it entire paragraph go below the yellow line (without changing display to flex, or grid, etc. which would stop it from flowing altogether)
.myfloat {
float: left;
width: 420px;
height: 100px;
background: yellow;
}
.hanging-indent {
text-indent: -20px; /* Negative value to indent the first line to the left */
margin-left: 20px; /* Positive value to offset subsequent lines */
width: 400px;
}
<div class="myfloat">
</div>
<p class="hanging-indent">
L ipsum dolor sit amet, consectetur adipiscing elit. Ut eget lorem nunc. Nulla facilisi. Nam feugiat velit vel turpis malesuada, in sodales risus tristique. Vestibulum sagittis vehicula nunc, non hendrerit odio ultrices et. Fusce consectetur eget turpis eu lobortis. Lo ipsum dolor sit amet, consectetur adipiscing elit. Ut eget lorem nunc. Nulla facilisi. Nam feugiat velit vel turpis malesuada, in sodales risus tristique. Vestibulum sagittis vehicula nunc, non hendrerit odio ultrices et. Fusce consectetur eget turpis eu lobortis.
</p>
2
Answers
This may not be ideal for whatever your needs are, but the real issue is with the float. If you can just clear your float before the text then you are good to go.
Try using span tag for the indentation in paragraph.