Align an image inside paragraph in HTML5

1503 views html
-1

I used to just align="left" an img inside p tags before but align is not supported anymore in HTML5.

What's the recommended way of doing the code below in HTML5?

<p>
    <img src="foo.jpg" align="left" />
    some long text
</p>

answered question

As you know, align attribute is no more supported in HTML5, so you will have to use CSS.

Yeah but I'm looking for the recommended way, so is it just text-align:left; ?

"not supported anymore in HTML5" — It was deprecated in 1998 … two decades ago.

1 Answer

7

You can use

p img{
  float: left;
}

This rule will apply on all images under <p>

p img{
  float: left;
}
 <p>
        <img src="https://fakeimg.pl/30x30/?text=A"/>
        some long text
    </p>

posted this

Have an answer?

JD

Please login first before posting an answer.

Ads

Categories