How to style the first entry in a list differently

Let’s say you have a list of news stories but you want to style the first entry differently. It’s quite a common pattern that we all need to deal with at some point. Luckily ExpressionEngine allows you to do this in more that one way.

Counting the entries

EE has a count variable that literally provides a count on the entries in a list. The first will have a value of “1”, the second “2” and so on.

In this example our list of entries will all have the same styling:

{exp:channel:entries channel="news" limit='10'}
<article>
    <h1>{title}</h1>
    {summary}
</article>
{/exp:channel:entries}

So let’s say we want to apply a CSS class to the first article tag using a conditional tag with the count number so we can style it differently:

{exp:channel:entries channel="news" limit='10'}
<article {if count == 1}class="first"{/if}>
    <h1>{title}</h1>
    {summary}
</article>
{/exp:channel:entries}

Wasn’t that easy?

What if we wanted to use different HTML heading tag for the first entry? Let’s tweak our tag so that happens:

{exp:channel:entries channel="news" limit='10'}
<article>
{if count == 1}
  <h1>{title}</h1>
{if:else}
  <h2>{title}</h2>
{/if}
  {summary}
</article>
{/exp:channel:entries}

See what we’ve done here? If the entry count is “1” use a h1 tag for the title, otherwise use a h2.

Let’s tweak our example again so we use different HTML just for the first entry:

{exp:channel:entries channel="news" limit='10'}
{if count == 1}
  <article>
      <h1>{title}</h1>
      {summary}
      {body}
  </article>
{if:else}
  <section>
    <h2>{title}</h2>
    {summary}
  </section>
{/if}
{/exp:channel:entries}

What happens now, the first entry gets wrapped in an article tag, subsequent entries get wrapped in a section tag.

Let’s extend that a bit further. Say we want to style both the first and second entries differently:

{exp:channel:entries channel="news" limit='10'}
{if count == 1}
  <article class="first">
      <h1>{title}</h1>
      {summary}
      {body}
  </article>
{if:elseif count == 2}
  <article class="second">
    <h2>{title}</h2>
    {summary}
  </article>
{if:else}
  <section>
    <h2>{title}</h2>
    {summary}
  </section>
{/if}
{/exp:channel:entries}

See how we use an extended conditional to loop through the entries and provide different CSS classes for just the first two entries.

Finally, let’s say you wanted to style the last entry differently. ExpressionEngine has a total_results variable that’s available to do that.

{exp:channel:entries channel="news" limit='10'}
<article{if count == total_results} class="last"{/if}>
    <h1>{title}</h1>
    {summary}
    {if count == total_results}
        This is the last entry
    {/if}
</article>
{/exp:channel:entries}

What we’re doing here, if the entry is the last one we apply a CSS class name to the article tag, and provide a message “This is the last entry”.

Using two separate tags

Sometimes using two channel entries tags may be necessary, say to get the desired document structure.

In this example we’re using the first channel entries tag to pull in the first entry using an article tag, then listing subsequent entries in an aside tag.

{exp:channel:entries channel="news" limit="1"}
<article>
  <h1>{title}</h1>
  {summary}
  {body}
</article>
{/exp:channel:entries}

<aside>
{exp:channel:entries channel="news" limit="9" offset='1'}
  <h2>{title}</h2>
  {summary}
{/exp:channel:entries}
</aside>

Note the second tag is limited to nine entries, along with an offset="1" parameter. The offset tells ExpressionEngine to get the latest nine news entries except the first one.

Rob Allen's avatar
Rob Allen

I've been creating web sites since 1998, and working with ExpressionEngine since 2007, building and maintaining sites for individuals, charities, organisations and businesses. I love using EE to do…

Comments 29

November 22, 2025

ivan512

This is super useful! I always struggled with styling the first entry in my ExpressionEngine lists. Definitely saving this for later. Wish I had this guide when I was trying to figure out how to escape from duckov! It would have made things so much easier!

November 22, 2025

ivan512

escape from duckov escape from duckov ledx escape from duckov scavenger The ultimate one-stop-shop for Escape from Duckov. From detailed guides to a comprehensive wiki and community tools, it has everything you need to survive the pond. Crafted by players, for players. DuckovGame.com is your essential community hub for reliable tips, strategies, and insights you won’t find anywhere else. New to the game? This website is your best friend. It breaks down complex mechanics, guides you through early quests, and helps you get your webbed feet on the ground.

November 22, 2025

ivan512

No i’m not a human No i’m not a human Master the Ultimate No I’m not a Human Strategy Guide We provide the most comprehensive No I’m not a Human guides, detailed system requirement analysis, secure download channels, and professional gaming tutorials. Whether you’re a newcomer or a veteran player seeking to collect all endings, you’ll find everything you need here.

November 22, 2025

ivan512

The freak circus The freak circus A Psychological Horror Visual Novel Step into a world where reality bends and nightmares come alive. The Freak Circus is an immersive psychological horror visual novel that will challenge your perception of truth and fiction.

November 22, 2025

ivan512

Sort The Court Sort The Court Rule your entire kingdom with just two words: “Yes” or “No.” A charmingly simple and addictive game of royal judgment.Think you can be a good ruler? Juggle your treasury, population, and happiness one bizarre request at a time.Will you hire a skeleton for your army or fund a wizard’s quest to turn everyone into frogs? Hilarious and unpredictable choices await.Deceptively simple, surprisingly strategic. It’s the perfect game for a 10-minute break that accidentally turns into an hour.

November 22, 2025

ivan512

Pips game Pips game  Pips Game isn’t just another puzzle; it’s an unlimited, free online brain-teaser inspired by the New York Times, designed to captivate and challenge players of all skill levels.This game is a solid time-killer for my commute! Easy to pick up and play a quick round. My only wish is for a ‘save and quit’ feature mid-puzzle, sometimes I gotta hop off the bus real quick.

November 22, 2025

ivan512

Bomb it Bomb it Play Bomb It, the ultimate online multiplayer bomber game! Strategize, blast, and dominate arenas. Join millions on bombitonline.org for endless explosive fun!Bomb It 1 is an exciting online game where you strategically place bombs to blow up opponents in an arena. It’s an action-packed game perfect for quick and fun gaming sessions!Yes! All Bomb It games available on Kizi are completely free to play, allowing you to enjoy hours of explosive fun without any cost.

November 22, 2025

ivan512

Throw a potatoy Throw a potato Forget logic. Forget reason. Embrace the madness! In this game, the only way forward is to throw a potato… and then another… and another. Experience an endless, chaotic loop of pure, spud-flinging insanity. You have been warned.

November 22, 2025

ivan512

Spend bill gates money Spend bill gates money Ever wondered what you’d do with Bill Gates’ money? Now you can find out. We’ll give you his $130 billion fortune to spend on anything you desire. Buy a fleet of supercars, a private island, or donate it all to a good cause. Your billionaire journey starts here!

November 22, 2025

ivan512

Star Copy And Paste Free star symbols collection! Copy and paste Unicode star symbols instantly. Star text generator and aesthetic text tools for social media. ★☆ Browse complete star symbols collection. Classic stars, decorative stars, and Unicode characters. One-click copy to clipboard.

November 26, 2025

falsesecret

The game also fosters a wacky flip sense of humor—players often find themselves laughing at unexpected tumbles, bizarre landings, or exaggerated ragdoll physics that give Wacky Flip its iconic charm.

December 3, 2025

legacytape

ragdoll hit brings wild ragdoll physics into fast-paced battles where simplicity meets real challenge. Some stages demand multiple attempts, but the thrill of punching, kicking, and weapon-smashing your enemies makes every retry worth it.

December 6, 2025

yasirelectronics

At Yasir Electronics, discover an exciting range of kitchen and cooling appliances to enhance your space. From a reliable Water Dispenser, Ice Cream Maker Machine, and Slush Machine to a handy Waffle Maker, we’ve got it all. Explore our top-quality Commercial Chiller and Commercial Freezer options built for lasting performance.

December 6, 2025

Crown Furniture

At Crown Furniture, discover a world of elegance with our modern bedroom furniture, stylish center tables, and luxurious wing chairs in Lahore. Transform your living spaces with impeccable wardrobe designs and premium selections from our sofa store. Experience sophistication and comfort—visit Crown Furniture to create the home of your dreams!

December 6, 2025

Yamas Furniture

At Yamas Office Furniture, we offer a wide range of high-quality office furniture that combines style and comfort. Whether you’re looking for ergonomic office chairs in Islamabad or modern office furniture in Lahore, we have everything you need to create a productive and professional workspace. Visit Yamas Furniture for the best selection today!

December 6, 2025

Mayar Curtain

At Mayar Curtain, we offer an exquisite range of curtains that add elegance to any room. From chic living room curtains to luxurious royal curtains, our collection is designed to suit every taste. Explore modern room curtains and stylish TV lounge curtains to enhance the beauty of your home. Visit Mayar Curtain today!

December 6, 2025

Karachi Fire

At Karachi Fire Corporation, we provide top-tier fire safety equipment to protect your home and business. From essential fire extinguishers and fire doors in Karachi to comprehensive fire fighting training, we offer reliable solutions. As leading fire fighting companies in Pakistan, we ensure safety with quality road sign boards and expert fire protection services.

January 27, 2026

ivan512

EscapetheBackroomsLevel Comprehensive Escape the Backrooms resources including guides, wiki, maps, and strategies to help you navigate and escape the Backrooms.

January 27, 2026

ivan512

PokéPath TD Comprehensive PokéPath TD game resources including guides, wiki, Pokémon database, tier lists, and strategy tools. A fan-created site by fans, for fans.

January 27, 2026

ivan512

Spend Elon Musk’s Money We’ve handed you a virtual wallet loaded with $401 Billion—the estimated net worth of Elon Musk. Whether you want to buy a fleet of private jets, a collection of supercars, or just an endless supply of pizza, this is your chance to live the high life without real-world bank statements.