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 8530427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:14:48+00:00 2026-06-11T09:14:48+00:00

I have floated articles side by side that are 25% wide. I’m adding a

  • 0

I have floated articles side by side that are 25% wide. I’m adding a clear:both after every fourth element. However I need to insert a graphical section-break inbetween the elements. And it has to be inside the <ul>. To be valid I wrapped the “section-break” (the first li item in the sample underneath) into a <li> as well.

<ul>
    <li class="year"><h1>THIS IS A SECTION Break and 100% wide</h1></li>
    <li>This is a article and only 25% wide</li>
    <li>This is a article and only 25% wide</li>
    <li>This is a article and only 25% wide</li>
    <li>This is a article and only 25% wide</li>
</ul>

I want every fourth element to be a line break so I use …

ul li:nth-of-type(4n+1) { clear: both; }

However I want the li.year not to be affected by this behaviour so I tried this

ul li:not(.year):nth-of-type(4n+1) { clear: both; }

Right now the last <li> in my sample code above is floated into the next line but that shouldn’t happen since the first <li> isn’t one of the floated articles but contains a headline.

Is it possible to stack the :not and nth-of-type() selector onto each other?

  • 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-06-11T09:14:48+00:00Added an answer on June 11, 2026 at 9:14 am

    The selector you have —

    ul li:not(.year):nth-of-type(4n+1) { background: yellow; }
    

    — is perfectly correct (as shown by highlighting the selector).


    The issue is with how you’re using clear. It works if you use clear:right, and then clear:left on the following element:

    ul li:not(.year):nth-of-type(4n+1) { clear: right;  }
    ul li:not(.year):nth-of-type(4n+2) { clear: left;  }
    

    Edit per comments The stricken-out text is nonsense. The real issue, as per BoltClock’s answer, is that the :not pseudo-class doesn’t affect nth-of-type. Adjusting the selector offset works in this case by coincidence, but would not work if the :not pattern was different.

    ul li:not(.year):nth-of-type(4n+2) { clear: left;  }
    

    http://jsfiddle.net/8MuCU/

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

Sidebar

Related Questions

I need to have a floated element after the content/text that's supposed to flow
I have a html like this: The idea is that divs are floated left
I have a div that contains many floated child items. Each child item is
I have a menu of floated ul/li's (the ), that is with changing width,
I have an image that is floated to the left that wraps text around
I have a sidebar that is floated left, and then a main content area
I have two Divs that are floated right, but I would like one to
I have a website that uses float/clear method for having a 3 columns design
I have two divs floated left so that they appear next to each other.
I have a list of items that I am displaying in a floated list,

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.