Arrange radio buttons vertically in a table

I am attempting to display a vertical list of radio buttons within a table cell. Is this achievable? Here is the code snippet I am currently working with:

            <table>
            <tr>
                <td> First Name </td>
                <td> <input type="text" class="profile_input"> </td>
                <td> Student ID </td>
                <td> <input type="text" class="profile_input"> </td>
            </tr>
            <tr>
                <td> Last Name </td>
                <td> <input type="text" class="profile_input"> </td>
                <td> Class </td>
                <td> <select class="select_input">
                      <option value="volvo">V1L</option>
                      <option value="saab">V1C</option>
                      <option value="mercedes">V1E</option>
                      <option value="audi">V1F</option>
                    </select> 
                </td>
            </tr>
            <tr>
                <td> Address </td>
                <td > <input type="text" class="profile_input size2"> </td>
                <td> Field of Study </td>
                <td > SNE <input type="radio" class="profile_input" name="FieldofStudy"> </td>
                <td > BIM <input type="radio" class="profile_input" name="FieldofStudy"> </td>
                <td > SIE <input type="radio" class="profile_input" name="FieldofStudy"> </td>
                <td > SNE <input type="radio" class="profile_input" name="FieldofStudy"> </td>
            </tr>
            <tr>
                <td> Email </td>
                <td> <input type="text" class="profile_input"> </td>
            </tr>
            <tr>
                <td> Phone Number </td>
                <td> <input type="text" class="profile_input"> </td>
            </tr>
            <tr>
                <td> Gender </td>
                <td> Male<input type="radio"  name="gender" class="profile_input"> 
                Female<input type="radio"  name="gender" class="profile_input"> </td>
            </tr>
            <tr>
                <td> Date of Birth </td>
                <td> <input type="date" class="profile_input"> </td>
            </tr>
        </table> 

Alongside the CSS styling for the table:

table {
width:100%;
margin-top:25px;
margin-bottom:25px;
}

input[type="text"], input[type="date"], .select_input {
    min-height:30px;
    border:1px solid black;
    padding:5px;    
    width:75%;
}
table tr {
    padding-bottom:5px;
}

.size2 {
    min-height:60px!important;
}

Currently, the table consists of a left side and a right side. The left side is basic, while the right side needs to include a list of four radio buttons displayed vertically.

Answer №1

To organize them neatly, you can group them in a fieldset and wrap them with labels. Then, in your CSS code, set the label display property to block.

HTML

      <td name="Studierichting">
        <fieldset>
          <label><input type="radio" class="profiel_inp" name="Studierichting">SNE</label>
          <label><input type="radio" class="profiel_inp" name="Studierichting">BIM</label>
          <label><input type="radio" class="profiel_inp" name="Studierichting">SIE</label>
          <label><input type="radio" class="profiel_inp" name="Studierichting">SNE</label>
        </fieldset>

CSS

label {
  display:block;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Embarking on the journey of nesting components within styled-components

Check out these custom components I created: <UserImg imgUrl={userPhoto}> <DropDown> <div onClick={handleAuth}>Sign Out</div> </DropDown> </UserImg> const DropDown = styled.div` letter-spacing: 0.2em; positi ...

The visibility of content that flickers on the webpage should be hidden with the display: none property during loading

Currently working on a new toy website, but encountering some unexpected behavior. On the homepage HTML file, there are two separate sets of <body> tags: <body class = "intro">...</body> <body class = "home">...</body& ...

I'm struggling to find the correct media query to fix the problem with resizing my window

Looking to create a layout where two large icons are displayed side by side horizontally, but then switch to a vertical layout when the window size is reduced (such as on a mobile phone). I know that media queries are necessary for this, but I am unsure of ...

The CSS Bootstrap 4 class 'input-group-append' is not functioning properly. Just recently, the styles were displaying correctly

My web application using AngularJS 1.7.8, jQuery 3.3.1, Bootstrap 4.3.1, and various other CSS and JS libraries worked seamlessly last week. However, today I noticed an issue with the button visualization. To Replicate: Visit openskymap.org to see my d ...

Integrating blade code within blade code

Struggling to craft a button using the Form builder. {!! Form::button('<span style="color: {!! $colour[$i] !!}" class..') !!} The specific details of the button don't matter, all I wanted was to adjust the font color to $colour[$id]. Th ...

What is the best method for adding anchors or appending items in aspx pages?

I have created code for an image gallery on my webpage, "gallery.aspx". The situation is that I have an external aspx page with various links. When a user clicks on one of these links, I want them to be redirected to the image gallery but to a specific ima ...

Tips for ensuring the final row remains fixed at the bottom of the table while maintaining a minimal body height:

I'm currently working on designing an invoice table using HTML and CSS. I have dynamic rows that are added to the table, and I want the body of the table to have a minimum height to fit around 5-6 rows, after which it should extend based on the number ...

Trouble with the JQuery event listener onchange()

On my webpage, I've set up a drop-down list and a text-box in the following HTML code: <table> <tr> <td>Group Name: </td> <td><%= Html.Dr ...

How to toggle between two background colors in a webpage with the click of a button using JavaScript

I need help with a unique website feature. I want to implement a button that cycles between two different background colors (white and black) as well as changes the font color from black to white, and vice versa. My goal is to create a negative version of ...

Enhance your Datatables experience with the inclusion of a select form

Here is the code I am working with: Javascript: $(document).ready(function() { $('#example').DataTable( { "ajax": '../ajax/data/arrays.txt' } ); } ); HTML <select id="office-select" name="idOffice"> <op ...

Exploring the process of web scraping from dynamic websites using C#

I am attempting to extract data from using HtmlAgilityPack. The website is dynamic in nature, displaying content after the page has fully loaded. Currently, my code retrieves the HTML of the loading bar using this method, but encounters a TargetInvocation ...

Adjusting the URL variable based on the selected checkbox option

My mobile website offers users the option of a bright or dark interface using a checkbox styled like an iPhone IOS7 switch. The functionality is working as expected, but I'm now facing an issue with passing the status of the checkbox between pages. I ...

Input field, upon receiving focus, triggers a subtle shift in the position of the submit button

Thank you for the assistance, I believe this issue should be an easy fix. I have added a custom :focus style to my input that removes the default outline and adds a box shadow and border. However, when the input field is focused, the submit button located ...

The error alert must be displayed directly beneath the specific box

When error messages occur in this code, they are displayed through an alert box. However, I would prefer to have the error message appear below the specific text box instead. This means that when I click on the submit button and a field is left empty, the ...

What is the method for obtaining the div ID's from this form?

This is the scenario I am working on: my app takes the text inputted by the user and exports it to a specific website that contains similar elements. For example, if the user enters a title in the app and clicks a button, the app will transfer that value t ...

Top method for removing quotation marks from form input using jquery

Here is a form input that I need to handle: <tr class="formulaRow"> <input type="text" class="ingredient required" name="ingredient"> </tr> Currently, the value from this input is stored as follows: var ingredient = $(".formulaRow").fi ...

CSS media query to target specific viewport width

In my JavaScript code, I am dynamically creating a meta viewport. I set the value of this viewport to be 980px using the following script: var customViewPort=document.createElement('meta'); customViewPort.id="viewport"; customViewPort.name = "vie ...

Place background image in the center with a background color overlay

After browsing through this post on Stack Overflow, I managed to stretch my background image using CSS with the background-size: cover; property. However, I realized that this solution doesn't completely meet my needs. I'm dealing with an image ...

Let's apply some CSS to the font style within the body

I've been incorporating a "footer.php" page into all other pages of my website. This footer showcases the site's name at the bottom of the screen and uses a custom font loaded with @font-face. Initially, I had something like this placed inside t ...

What is the best way to add a value to the value attribute of a div using JavaScript?

Is there a way to insert a value into the value attribute of a div using Internet Explorer 9? I have attempted various JavaScript functions, but so far I can only modify the content inside the div and not the value attribute itself. <div id="mydiv" val ...