user5041486
user5041486

Reputation:

Last-Of Type and Last-Of-Child

HTML:

<div class="plan-box">
    <h3>...</h3>
    <p>...</p>
</div>

<div class="plan-box">
    <h3>...</h3>
    <p>...</p>
</div>

CSS:

.plan-box:last-of-type {
    ...
}

In the above CSS code if I use last-of-type or last-child css selector on .plan-box will that select the last-child in both the .plan-box div which is the paragraph or will it select the second .plan-box div in the HTML code?

Upvotes: 0

Views: 177

Answers (2)

Erkan Demirel
Erkan Demirel

Reputation: 4382

.plan-box:last-child Selects last of plan.box element

.plan-box :last-child Selects last elements in all of plan.box elements

Css Selectors

Upvotes: 1

Chonchol Mahmud
Chonchol Mahmud

Reputation: 2735

It will select second .plan-box div in the HTML code.

See the Link here

Again you can easily select any child div with CSS .Example is Here I have used here .plan-box:nth-child(2) {} for select second div.

Upvotes: 0

Related Questions