The <img> style in <figure>

I cannot create a style for an image inside a shape:

HTML:

<article>
    <p>

    <figure class="float-right">
        <img src="images/castle1.jpg">
        <figcaption>The castle by day</figcaption>
    </figure> 

    </p>
</article>

CSS

article p figure img {
    height: 330px;
    width: 500px;
    float: right;
    margin: 10px 20px 20px 20px;
    background-color: green;
    border-radius: 4px;
}

You can view the site here.

+4
source share
2 answers

pcannot contain figure. The only content that is allowed in an element pis phrased content that figuredoes not classify as.

, figure , p, <p> ( ... . img figure, p, DOM , .

p - , , :

article figure img {
    height: 330px;
    width: 500px;
    float: right;
    margin: 10px 20px 20px 20px;
    background-color: green;
    border-radius: 4px;
}
+9

.float-right img {
  height: 330px;
  width: 500px;
  float: right;
  margin: 10px 20px 20px 20px;
  background-color: green;
  border-radius: 4px;
}

+3

Source: https://habr.com/ru/post/1530525/


All Articles