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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:28:12+00:00 2026-05-10T15:28:12+00:00

Given the code bellow, how do I style the radio buttons to be next

  • 0

Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels?

<link href='http://yui.yahooapis.com/2.5.2/build/reset-fonts-grids/reset-fonts-grids.css' rel='stylesheet'> <link href='http://yui.yahooapis.com/2.5.2/build/base/base-min.css' rel='stylesheet'>  <div class='input radio'>   <fieldset>     <legend>What color is the sky?</legend>     <input type='hidden' name='color' value='' id='SubmitQuestion' />     <input type='radio' name='color' id='SubmitQuestion1' value='1'  />     <label for='SubmitQuestion1'>A strange radient green.</label>     <input type='radio' name='color' id='SubmitQuestion2' value='2'  />     <label for='SubmitQuestion2'>A dark gloomy orange</label>     <input type='radio' name='color' id='SubmitQuestion3' value='3'  />     <label for='SubmitQuestion3'>A perfect glittering blue</label>   </fieldset> </div>

Also let me state that I use the yui css styles as base. If you are not familir with them, they can be found here:

  • reset-fonts-grids.css
  • base-min.css

Documentation for them both here : Yahoo! UI Library

@pkaeding: Thanks. I tried some floating both thing that just looked messed up. The styling active radio button seemed to be doable with some input[type=radio]:active nomination on a google search, but I didnt get it to work properly. So the question I guess is more: Is this possible on all of todays modern browsers, and if not, what is the minimal JS needed?

  • 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. 2026-05-10T15:28:13+00:00Added an answer on May 10, 2026 at 3:28 pm

    The first part of your question can be solved with just HTML & CSS; you’ll need to use Javascript for the second part.

    Getting the Label Near the Radio Button

    I’m not sure what you mean by ‘next to’: on the same line and near, or on separate lines? If you want all of the radio buttons on the same line, just use margins to push them apart. If you want each of them on their own line, you have two options (unless you want to venture into float: territory):

    • Use <br />s to split the options apart and some CSS to vertically align them:
    <style type='text/css'>     .input input     {         width: 20px;     } </style> <div class='input radio'>     <fieldset>         <legend>What color is the sky?</legend>         <input type='hidden' name='data[Submit][question]' value='' id='SubmitQuestion' />          <input type='radio' name='data[Submit][question]' id='SubmitQuestion1' value='1'  />         <label for='SubmitQuestion1'>A strange radient green.</label>         <br />         <input type='radio' name='data[Submit][question]' id='SubmitQuestion2' value='2'  />         <label for='SubmitQuestion2'>A dark gloomy orange</label>         <br />         <input type='radio' name='data[Submit][question]' id='SubmitQuestion3' value='3'  />         <label for='SubmitQuestion3'>A perfect glittering blue</label>     </fieldset> </div> 
    • Follow A List Apart‘s article: Prettier Accessible Forms

    Applying a Style to the Currently Selected Label + Radio Button

    Styling the <label> is why you’ll need to resort to Javascript. A library like jQuery is perfect for this:

    <style type='text/css'>     .input label.focused     {         background-color: #EEEEEE;         font-style: italic;     } </style> <script type='text/javascript' src='jquery.js'></script> <script type='text/javascript'>     $(document).ready(function() {         $('.input :radio').focus(updateSelectedStyle);         $('.input :radio').blur(updateSelectedStyle);         $('.input :radio').change(updateSelectedStyle);     })      function updateSelectedStyle() {         $('.input :radio').removeClass('focused').next().removeClass('focused');         $('.input :radio:checked').addClass('focused').next().addClass('focused');     } </script> 

    The focus and blur hooks are needed to make this work in IE.

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

Sidebar

Ask A Question

Stats

  • Questions 128k
  • Answers 128k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer use getComponentStack() method from the org.apache.struts2.components.Component class. May 12, 2026 at 5:44 am
  • Editorial Team
    Editorial Team added an answer setlocal enabledelayedexpansion set outfile=%1.copy del "%outfile%" for /f "delims=" %%x… May 12, 2026 at 5:44 am
  • Editorial Team
    Editorial Team added an answer CGI has been replaced by a vast variety of web… May 12, 2026 at 5:44 am

Related Questions

Assuming I have the superclass A, and the subclasses A1 and A2 which inherit
The question How can I monkey-patch an instance method in Perl? got me thinking.
I'm trying to come up with an answer to two questions that didn't seem
Possible Duplicate: Why do I get a segmentation fault when writing to a string?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.