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

  • SEARCH
  • Home
  • 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 6922683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:26:16+00:00 2026-05-27T10:26:16+00:00

Let’s say I have the following HTML: <ul> <li id=1>First issue.</li> <li id=2 class=error>Second

  • 0

Let’s say I have the following HTML:

<ul>
    <li id="1">First issue.</li>
    <li id="2" class="error">Second issue.</li>
    <li id="3" class="error">Third issue.</li>
    <li id="4">Fourth issue.</li>
    <li id="5" class="error">Fifth issue.</li>
    <li id="6" class="error">Sixth issue.</li>
    <li id="7" class="error">Seventh issue.</li>
    <li id="8" class="error">Eighth issue.</li>
    <li id="9">Ninth issue.</li>
    <li id="10" class="error">Tenth issue.</li>
</ul>

And the following CSS:

.error {
    background-color: rgba(255, 0, 0, 0.2);
}

What I’m looking to do is to style the first and last <li> in a sequence styled different than other <li>s that are in the middle.

For example, #2, #5, #10 should all match the “first in sequence selector”; #3, #8, #10 should be matched by the “last in sequence selector.”

I’d like to apply the following styles to “first-in-sequence” and “last-in-sequence”, respectively:

.firstInSequence {
    border-radius-top-right: 10px;
    border-radius-top-left: 10px;
}

.lastInSequence {
    border-radius-bottom-right: 10px;
    border-radius-bottom-left: 10px;
}

Are there selectors I could use to do this natively in CSS?

  • 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-27T10:26:16+00:00Added an answer on May 27, 2026 at 10:26 am

    As stated in the other answers, you can style the ‘first of sequence’ using the :not and :first-child pseudo selector:

    :not(.error) + .error,
    .error:first-child {
        border-top-right-radius: 10px;
        border-top-left-radius: 10px;
    }
    

    I think I’ve found a solution for ‘last of sequence’ in this scenario with rounded corners. It uses a completely different method of accomplishing the finished product, but ends with a similar result:

    Rounded Corners on last of sequence

    The basic technique is to apply pseudo-elements with radial-gradients to list items that are not .error. after .errors, and move them up over the previous (.error) list item:

    .error + :not(.error):before {
        content:'';
        display:block;
        width:10px;
        height:10px;
        position:absolute;
        top:-20px;
        left:0;
        background:-webkit-radial-gradient(100% 0,circle,transparent 10px,white 0);
    }
    
    .error + :not(.error):after {
        content:'';
        display:block;
        width:10px;
        height:10px;
        position:absolute;
        top:-20px;
        right:0;
        background:-webkit-radial-gradient(0 0,circle,transparent 10px,white 0);
    }
    

    Make sure li has position:relative;.

    Finally, for a border-radius on the last one, use last-of-type:

    .error:last-of-type{
        border-bottom-right-radius:10px;
        border-bottom-left-radius:10px
    }
    

    Demo (Webkit only for simplicity)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have the following entity: public class Store { public List<Product> Products
Let's say I have the following models class Photo(models.Model): tags = models.ManyToManyField(Tag) class Tag(models.Model):
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have an facebook application running using the JS SDK. First user
let's say I have the following string: string s = A B C D
Let say I have the following desire, to simplify the IConvertible's to allow me
Let say I have some code HTML code: <ul> <li> <h1>Title 1</h1> <p>Text 1</p>
Let's say I have the following function in C#: void ProcessResults() { using (FormProgress

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.