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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:01:43+00:00 2026-06-07T09:01:43+00:00

input:required{ background-color:#f00; } input:required label{ color: #FF3434; } I have the above CSS code

  • 0
input:required{
    background-color:#f00;
}

input:required label{
   color: #FF3434;
}

I have the above CSS code currently for my form,

I want to be able to make the label red when the field is required. My input field is:

<label for="frmComTelephone">Telephone</label>  
<input type="number" name="Telephone" id="frmComTelephone"/>

<label for="frmIn1IncinTime">Time</label>   
<input type="text" name="Incident Time" id="frmIn1IncinTime" required="required"/><br>

But that CSS isn’t working how do I solve this?

2ND problem is I have the following CSS:

input:focus 
{ 
    background-color:yellow;
}

input[type="text"], input[type="date"],input[type="time"],input[type="number"],textarea,select
{
border-radius:5px;
border-width: 1px;
border-style: solid;
border-color: #C6C6C6; 
height:41px;
background-color: #FF3434;
width: 100%;

}

But when the item is focused it doesn’t change to yellow, if i remove “background-color: #FF3434;” it turns yellow on focus?

Is what I am doing not able to be done? Or am I going about this wrong?

Thanks

  • 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-07T09:01:46+00:00Added an answer on June 7, 2026 at 9:01 am

    Issue 1:

    input:required label{
       color: #FF3434;
    }
    

    This won’t work because the label is not a child of the input. They’re siblings. To solve that you have to create a class and attach it to your label:

    label.required { color: #FF3434; }
    <label for="frmComTelephone" class="required">Telephone</label>  
    

    Issue 2:

    Try this:

    input:focus,
    textarea:focus,
    select:focus
    { background-color: yellow !important; }
    

    …

    UPDATE

    If you’re more comfortable without using !important then try this:

    input[type="text"]:focus, 
    input[type="date"]:focus,
    input[type="time"]:focus,
    input[type="number"]:focus,
    textarea:focus,
    select:focus
    { background-color: yellow }
    

    OR

    if you have an id on your form this will also work

    #formID input:focus,
    #formID textarea:focus,
    #formID select:focus
    { background-color: yellow }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<form name=author-form accept-charset=utf-8 method=post> <input type=checkbox id=checklist-1 name=checklist[] value=0 required /></td> <label for=checklist-1>The submission
I have the following code: index.jsp: <form name=f action=db/ajoutConducteur.jsp method=post> <input type=text pattern=\d{8} required
How should I mark input fields as invalid (i.e. color, background-color, border, etc.) Currently,
Look at this: $('form).submit(function (event) { $(':input.required').trigger('blur'); var num = $('.warning', this).length; alert(num);//Focus here!
I am wanting to check if input fields have the attribute required. If these
I have a form with two input textboxes, and I have included jQuery validation
I have a form with a text input box which displays similar entries to
I have a for loop that goes through each input with class=required , and
I am currently working on an HTML, CSS, PHP project. I want to display
Please take a look at this example in Chrome browser: http://jsfiddle.net/ymzTB/ <form> <input required

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.