0

I have paragraphs inside a div, and I want to add border-bottom-left-radius to the first p element inside the div, but it doesn't work:

p {
  display: inline-block;
  border: 1px solid #000;
}
div:first-child {
  border-bottom-left-radius: 5px;
}
<div>
    <p>1</p>
    <p>2</p>
    <p>3</p>
</div>

The same happens with :last-child, border-top-left-radius, border-top-right-radius, border-bottom-right-radius.

What is the problem? This and this similar questions were fixed with the background, but I have none. Attempting to read the specifications I found nothing related to the paragraph element or pseudo-class selectors.

1 Answers1

1

From documentation:

The :first-child CSS pseudo-class represents the first element among a group of sibling elements.

you need to apply it to the p element, not div element.

p {
  display: inline-block;
  border: 1px solid #000;
}
div p:first-child {
  border-bottom-left-radius: 5px;
}
<div>
    <p>1</p>
    <p>2</p>
    <p>3</p>
</div>
Nikes
  • 1,094
  • 8
  • 13