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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:22:44+00:00 2026-05-23T11:22:44+00:00

Given the following <div class=item> <p class=itemClass><input type=text id=1 name=field1 /><p> <p class=itemClass><input type=text

  • 0

Given the following

<div class="item">
    <p class="itemClass"><input type="text" id="1" name="field1" /><p>
    <p class="itemClass"><input type="text" id="2" name="field2" /><p>
</div>
<div class="item">
    <p class="itemClass"><input type="text" id="3" name="field3" /><p>
    <p class="itemClass"><input type="text" id="4" name="field4" /><p>
</div>
<div class="item">
    <p class="itemClass"><input type="text" id="5" name="field5" /><p>
    <p class="itemClass"><input type="text" id="6" name="field6" /><p>
</div>
..............etc

How could I target so that odd number fields style differently to even number fields.
I thought maybe I could swap out the P tags for lesser used h tags like..

<div class="item">
    <h4 class="itemClass"><input type="text" id="5" name="field5" /><h4>
    <h5 class="itemClass"><input type="text" id="6" name="field6" /><h5>
</div>

But I’m not sure how I would select each field. Currently I am using…

.itemclass input{
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
margin-top: 0px;
padding: 1px 0px 1px 0px;
background:url(images/input-trans.png) repeat-x right center;
color: black;
border-color: white;
}

But clearly that apply’s to both inputs

thx

  • 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-23T11:22:45+00:00Added an answer on May 23, 2026 at 11:22 am

    I agree with longchiwen that nth-child pseudoclass is probably the best solution for modern browsers with CSS3 support.

    If you want to support browsers which do not understand this pseudoclass, the bulletproof solution would be using additional class for even items:

    <div class="item">
        <p class="itemClass"><input type="text" id="1" name="field1" /><p>
        <p class="itemClass even"><input type="text" id="2" name="field2" /><p>
    </div>
    

    As you can see, you can assign many classes (space separated) to the tag.

    And in CSS you just write:

    .even input {
        background-color: #c0ffee
    }
    

    I’d also recommend to beautify the code by getting rid of itemClass class and use .item p instead of .itemClass.

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

Sidebar

Related Questions

Given the following CSS3 animation.... <style type=text/css media=screen> .drop_box { -webkit-animation-name: drop; -webkit-animation-duration: 2s;
Given the following: <div class=filters id=filters> <select id=state name=state tabindex=1 > <option value=>Filter by
Given the following mark-up... <div id=Header> <a href=# class=Highlight>foo</a> </div> And the following stylesheet...
Given the following markup <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML Strict//EN><META http-equiv=Content-Type content=text/html; charset=utf-8> <HTML
I'm having trouble selecting the input value from this html: <li class=t-item> <div class=t-mid>
Given the following HTML structure: <div id=wrapper> <div id=top> <a href=http://example.com class=link>click here</a> </div>
Given the following HTML snippet: <div class=image> <div class=placeholder> <a class=load iframe href=https://contestapp.com/images/4><img src=/uploads/image/image_file/4/thumb_he_sport_nutrition_for_active_kids_photo.jpg?1307271623
Given the following html... <div id=group> <ul> <li><div class=category>one</div></li> <li><div class=category>one</div></li> <li><div class=category>onetwo</div></li> <li><div
Given the following HTML: <div class=component> <div class=component> <div class=component> </div> </div> <div class=component>
Given the following HTML on a page: <div class='test'> <p><span id='id1' class='test1 test2 test3'>test

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.