Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6547687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:51:42+00:00 2026-05-25T11:51:42+00:00

<div class=commentList> <article class=comment id=com21></article> <article class=comment id=com20></article> <article class=comment id=com19></article> <div class=something> hello

  • 0
<div class="commentList">
   <article class="comment " id="com21"></article>
   <article class="comment " id="com20"></article>
   <article class="comment " id="com19"></article>
   <div class="something"> hello </div>
</div>

I want to select #com19 ?

.comment {
    width:470px;
    border-bottom:1px dotted #f0f0f0;
    margin-bottom:10px;
}

.comment:last-child {
    border-bottom:none;
    margin-bottom:0;
}

That does not work as long as I do have another div.something as actual last child in the commentList. Is it possible to use the last-child selector in this case to select the last appearance of article.comment?

jsFiddle

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:51:42+00:00Added an answer on May 25, 2026 at 11:51 am

    :last-child only works when the element in question is the last child of the container, not the last of a specific type of element. For that, you want :last-of-type

    http://jsfiddle.net/C23g6/3/

    As per @BoltClock’s comment, this is only checking for the last article element, not the last element with the class of .comment.

    body {
      background: black;
    }
    
    .comment {
      width: 470px;
      border-bottom: 1px dotted #f0f0f0;
      margin-bottom: 10px;
    }
    
    .comment:last-of-type {
      border-bottom: none;
      margin-bottom: 0;
    }
    <div class="commentList">
      <article class="comment " id="com21"></article>
    
      <article class="comment " id="com20"></article>
    
      <article class="comment " id="com19"></article>
    
      <div class="something"> hello </div>
    </div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<div class=commentList> <article class=comment id=com21></article> <article class=comment id=com20></article> <article class=comment id=com19></article> </div> Any idea
Let's say I do something stupid like this: <div class=my_class>fun wee!!</div> <span class=my_class><b class=my_class>Title</b></span>
$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
I can select the first item in the div using $('.class:first') Now since I
I have many DIV with the same class name, let save wmplayer. I want
I have a list like this: <div class=commentList> <div name=version-1>stuff</div> <div name=version-1>stuff</div> <div name=version-1>stuff</div>
In stylesheets you often see div#id { /* something */ } and div.class {
I want to locate a div and replace both the content and div class
I want to apply the rules in a CSS file to a certain div/class
I wrapped a class but i only want to wrap the first div.class productInfo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.