Html form stylingAdding HTML entities using CSS contentConvert HTML + CSS to PDF with PHP?Retrieve the position (X,Y) of an HTML elementHow to style a <select> dropdown with only CSS?How can I remove a style added with .css() function?How to style a checkbox using CSS?iOS forces rounded corners and glare on inputsHTML Simple Form Text Input Styleoffsetting an html anchor to adjust for fixed headerHow to have different input text styles in same html form?

Sequence of Tenses: Translating the subjunctive

How does it work when somebody invests in my business?

How to be diplomatic in refusing to write code that breaches the privacy of our users

Is expanding the research of a group into machine learning as a PhD student risky?

Are student evaluations of teaching assistants read by others in the faculty?

How can we prove that any integral in the set of non-elementary integrals cannot be expressed in the form of elementary functions?

Pre-amplifier input protection

Why, precisely, is argon used in neutrino experiments?

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

Roman Numeral Treatment of Suspensions

Was Spock the First Vulcan in Starfleet?

How to pronounce the slash sign

Crossing the line between justified force and brutality

Why not increase contact surface when reentering the atmosphere?

Method to test if a number is a perfect power?

Opposite of a diet

Purchasing a ticket for someone else in another country?

CREATE opcode: what does it really do?

Is a stroke of luck acceptable after a series of unfavorable events?

Is there a good way to store credentials outside of a password manager?

Different result between scanning in Epson's "color negative film" mode and scanning in positive -> invert curve in post?

How can I kill an app using Terminal?

Class Action - which options I have?

What is the best translation for "slot" in the context of multiplayer video games?



Html form styling


Adding HTML entities using CSS contentConvert HTML + CSS to PDF with PHP?Retrieve the position (X,Y) of an HTML elementHow to style a <select> dropdown with only CSS?How can I remove a style added with .css() function?How to style a checkbox using CSS?iOS forces rounded corners and glare on inputsHTML Simple Form Text Input Styleoffsetting an html anchor to adjust for fixed headerHow to have different input text styles in same html form?













-2















I have a form that looks like this:



Form



It's a pretty big form so I only show the divs



As you can see this form doesn't look good, and I want it to look better, but I am very bad at styling. all that I want is to do is that the input fields are next to eachother. I alread tried this:






#formdiv 
max-width: 500px;
padding: 20px 12px 10px 20px;
font: 13px Arial, Helvetica, sans-serif;


#form
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
background-color: #cccccc;

<div id='formdiv'>
<form id="form" action="" method="get">
</form>
</div>





could you please help me? thank you.



EDIT



I want it to be more user friendly



EDIT 2



 <div id='formdiv'>
<form id="form" action="" method="get">
<?php
$g = 1;
$vrij = '';
foreach ($alla as $rowa)

if($g==1):
$vrij = $rowa['Field'];
else:
$vrij .= ',' . $rowa['Field'];
endif;
$g++;
$int = str_replace("int", null, $rowa['Type']);
$varchar = str_replace("varchar", null, $rowa['Type']);
switch($rowa['Type'])

case 'int'.$int.'':
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'];
echo '<input type="text" name="box" id="box'.$rowa['Field'].'">';
echo '<select id="keuzes" name="keuzes">';
echo '<option value="som op" id="btn'.$rowa['Field'].'">som op</option>';
echo '<option value="kleinder dan" id="kd'.$rowa['Field'].'">kleinder dan</option>';
echo '<option value="grooter dan" id="gd'.$rowa['Field'].'">grooter dan</option>';
echo '<option value="kleinder of gelijk aan" id="koga'.$rowa['Field'].'">kleinder of gelijk aan</option>';
echo '<option value="grooter of gelijk aan" id="goga'.$rowa['Field'].'">grooter of gelijk aan</option>';
echo '<option value="tel op" id="to'.$rowa['Field'].'">tel op</option>';
echo '</select><br>';
break;
case 'varchar'.$varchar.'':
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'];
echo '<input type="text" name="box" id="box'.$rowa['Field'].'">';
echo '<input type="button" value="zoek naar" id="zn'.$rowa['Field'].'">' . '<br>';

break;
case "datetime":
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field']. '<br>';
echo 'Begin tijd <input type="text" name="begin" id="begin' . $rowa['Field'] . '">' . '<br>';
echo 'Eind tijd <input type="text" name="end" id="end' . $rowa['Field'] . '">' . '<br>';
echo 'Een tijd <input type="text" name="box" id="box'.$rowa['Field'].'">'. '<br>';
break;
case "longtext":
echo '<input type="checkbox" name="A" id="actionc" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'] . '<br>';
break;



?>
<br>
<input type="submit" id="submit" name="submit" value="submit"><br>
</form>
</div>


EDIT 3



how I want my form to look



this is how I want my form to look like.










share|improve this question



















  • 2





    doesn't look good, and I want it to look better - only you know what is good.

    – BladeMight
    Mar 8 at 11:07











  • @BladeMight well I want it to be more user friendly

    – john snow
    Mar 8 at 11:08






  • 2





    Provide the html

    – Hemant Parashar
    Mar 8 at 11:09






  • 1





    Please provide the full html or a JSFiddle / Codepen example

    – Matt.Hamer5
    Mar 8 at 11:11






  • 1





    U have a proposition of how you want it to look like ? I don't know it others can help but I find it hard because You didnt say how your from has to look like

    – TaouBen
    Mar 8 at 11:19















-2















I have a form that looks like this:



Form



It's a pretty big form so I only show the divs



As you can see this form doesn't look good, and I want it to look better, but I am very bad at styling. all that I want is to do is that the input fields are next to eachother. I alread tried this:






#formdiv 
max-width: 500px;
padding: 20px 12px 10px 20px;
font: 13px Arial, Helvetica, sans-serif;


#form
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
background-color: #cccccc;

<div id='formdiv'>
<form id="form" action="" method="get">
</form>
</div>





could you please help me? thank you.



EDIT



I want it to be more user friendly



EDIT 2



 <div id='formdiv'>
<form id="form" action="" method="get">
<?php
$g = 1;
$vrij = '';
foreach ($alla as $rowa)

if($g==1):
$vrij = $rowa['Field'];
else:
$vrij .= ',' . $rowa['Field'];
endif;
$g++;
$int = str_replace("int", null, $rowa['Type']);
$varchar = str_replace("varchar", null, $rowa['Type']);
switch($rowa['Type'])

case 'int'.$int.'':
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'];
echo '<input type="text" name="box" id="box'.$rowa['Field'].'">';
echo '<select id="keuzes" name="keuzes">';
echo '<option value="som op" id="btn'.$rowa['Field'].'">som op</option>';
echo '<option value="kleinder dan" id="kd'.$rowa['Field'].'">kleinder dan</option>';
echo '<option value="grooter dan" id="gd'.$rowa['Field'].'">grooter dan</option>';
echo '<option value="kleinder of gelijk aan" id="koga'.$rowa['Field'].'">kleinder of gelijk aan</option>';
echo '<option value="grooter of gelijk aan" id="goga'.$rowa['Field'].'">grooter of gelijk aan</option>';
echo '<option value="tel op" id="to'.$rowa['Field'].'">tel op</option>';
echo '</select><br>';
break;
case 'varchar'.$varchar.'':
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'];
echo '<input type="text" name="box" id="box'.$rowa['Field'].'">';
echo '<input type="button" value="zoek naar" id="zn'.$rowa['Field'].'">' . '<br>';

break;
case "datetime":
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field']. '<br>';
echo 'Begin tijd <input type="text" name="begin" id="begin' . $rowa['Field'] . '">' . '<br>';
echo 'Eind tijd <input type="text" name="end" id="end' . $rowa['Field'] . '">' . '<br>';
echo 'Een tijd <input type="text" name="box" id="box'.$rowa['Field'].'">'. '<br>';
break;
case "longtext":
echo '<input type="checkbox" name="A" id="actionc" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'] . '<br>';
break;



?>
<br>
<input type="submit" id="submit" name="submit" value="submit"><br>
</form>
</div>


EDIT 3



how I want my form to look



this is how I want my form to look like.










share|improve this question



















  • 2





    doesn't look good, and I want it to look better - only you know what is good.

    – BladeMight
    Mar 8 at 11:07











  • @BladeMight well I want it to be more user friendly

    – john snow
    Mar 8 at 11:08






  • 2





    Provide the html

    – Hemant Parashar
    Mar 8 at 11:09






  • 1





    Please provide the full html or a JSFiddle / Codepen example

    – Matt.Hamer5
    Mar 8 at 11:11






  • 1





    U have a proposition of how you want it to look like ? I don't know it others can help but I find it hard because You didnt say how your from has to look like

    – TaouBen
    Mar 8 at 11:19













-2












-2








-2








I have a form that looks like this:



Form



It's a pretty big form so I only show the divs



As you can see this form doesn't look good, and I want it to look better, but I am very bad at styling. all that I want is to do is that the input fields are next to eachother. I alread tried this:






#formdiv 
max-width: 500px;
padding: 20px 12px 10px 20px;
font: 13px Arial, Helvetica, sans-serif;


#form
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
background-color: #cccccc;

<div id='formdiv'>
<form id="form" action="" method="get">
</form>
</div>





could you please help me? thank you.



EDIT



I want it to be more user friendly



EDIT 2



 <div id='formdiv'>
<form id="form" action="" method="get">
<?php
$g = 1;
$vrij = '';
foreach ($alla as $rowa)

if($g==1):
$vrij = $rowa['Field'];
else:
$vrij .= ',' . $rowa['Field'];
endif;
$g++;
$int = str_replace("int", null, $rowa['Type']);
$varchar = str_replace("varchar", null, $rowa['Type']);
switch($rowa['Type'])

case 'int'.$int.'':
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'];
echo '<input type="text" name="box" id="box'.$rowa['Field'].'">';
echo '<select id="keuzes" name="keuzes">';
echo '<option value="som op" id="btn'.$rowa['Field'].'">som op</option>';
echo '<option value="kleinder dan" id="kd'.$rowa['Field'].'">kleinder dan</option>';
echo '<option value="grooter dan" id="gd'.$rowa['Field'].'">grooter dan</option>';
echo '<option value="kleinder of gelijk aan" id="koga'.$rowa['Field'].'">kleinder of gelijk aan</option>';
echo '<option value="grooter of gelijk aan" id="goga'.$rowa['Field'].'">grooter of gelijk aan</option>';
echo '<option value="tel op" id="to'.$rowa['Field'].'">tel op</option>';
echo '</select><br>';
break;
case 'varchar'.$varchar.'':
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'];
echo '<input type="text" name="box" id="box'.$rowa['Field'].'">';
echo '<input type="button" value="zoek naar" id="zn'.$rowa['Field'].'">' . '<br>';

break;
case "datetime":
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field']. '<br>';
echo 'Begin tijd <input type="text" name="begin" id="begin' . $rowa['Field'] . '">' . '<br>';
echo 'Eind tijd <input type="text" name="end" id="end' . $rowa['Field'] . '">' . '<br>';
echo 'Een tijd <input type="text" name="box" id="box'.$rowa['Field'].'">'. '<br>';
break;
case "longtext":
echo '<input type="checkbox" name="A" id="actionc" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'] . '<br>';
break;



?>
<br>
<input type="submit" id="submit" name="submit" value="submit"><br>
</form>
</div>


EDIT 3



how I want my form to look



this is how I want my form to look like.










share|improve this question
















I have a form that looks like this:



Form



It's a pretty big form so I only show the divs



As you can see this form doesn't look good, and I want it to look better, but I am very bad at styling. all that I want is to do is that the input fields are next to eachother. I alread tried this:






#formdiv 
max-width: 500px;
padding: 20px 12px 10px 20px;
font: 13px Arial, Helvetica, sans-serif;


#form
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
background-color: #cccccc;

<div id='formdiv'>
<form id="form" action="" method="get">
</form>
</div>





could you please help me? thank you.



EDIT



I want it to be more user friendly



EDIT 2



 <div id='formdiv'>
<form id="form" action="" method="get">
<?php
$g = 1;
$vrij = '';
foreach ($alla as $rowa)

if($g==1):
$vrij = $rowa['Field'];
else:
$vrij .= ',' . $rowa['Field'];
endif;
$g++;
$int = str_replace("int", null, $rowa['Type']);
$varchar = str_replace("varchar", null, $rowa['Type']);
switch($rowa['Type'])

case 'int'.$int.'':
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'];
echo '<input type="text" name="box" id="box'.$rowa['Field'].'">';
echo '<select id="keuzes" name="keuzes">';
echo '<option value="som op" id="btn'.$rowa['Field'].'">som op</option>';
echo '<option value="kleinder dan" id="kd'.$rowa['Field'].'">kleinder dan</option>';
echo '<option value="grooter dan" id="gd'.$rowa['Field'].'">grooter dan</option>';
echo '<option value="kleinder of gelijk aan" id="koga'.$rowa['Field'].'">kleinder of gelijk aan</option>';
echo '<option value="grooter of gelijk aan" id="goga'.$rowa['Field'].'">grooter of gelijk aan</option>';
echo '<option value="tel op" id="to'.$rowa['Field'].'">tel op</option>';
echo '</select><br>';
break;
case 'varchar'.$varchar.'':
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'];
echo '<input type="text" name="box" id="box'.$rowa['Field'].'">';
echo '<input type="button" value="zoek naar" id="zn'.$rowa['Field'].'">' . '<br>';

break;
case "datetime":
echo '<input type="checkbox" name="A" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field']. '<br>';
echo 'Begin tijd <input type="text" name="begin" id="begin' . $rowa['Field'] . '">' . '<br>';
echo 'Eind tijd <input type="text" name="end" id="end' . $rowa['Field'] . '">' . '<br>';
echo 'Een tijd <input type="text" name="box" id="box'.$rowa['Field'].'">'. '<br>';
break;
case "longtext":
echo '<input type="checkbox" name="A" id="actionc" value="'. $rowa['Field'] . '" id="'.$rowa['Field'].'">' .$rowa['Field'] . '<br>';
break;



?>
<br>
<input type="submit" id="submit" name="submit" value="submit"><br>
</form>
</div>


EDIT 3



how I want my form to look



this is how I want my form to look like.






#formdiv 
max-width: 500px;
padding: 20px 12px 10px 20px;
font: 13px Arial, Helvetica, sans-serif;


#form
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
background-color: #cccccc;

<div id='formdiv'>
<form id="form" action="" method="get">
</form>
</div>





#formdiv 
max-width: 500px;
padding: 20px 12px 10px 20px;
font: 13px Arial, Helvetica, sans-serif;


#form
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
background-color: #cccccc;

<div id='formdiv'>
<form id="form" action="" method="get">
</form>
</div>






css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 11:22







john snow

















asked Mar 8 at 11:04









john snowjohn snow

83




83







  • 2





    doesn't look good, and I want it to look better - only you know what is good.

    – BladeMight
    Mar 8 at 11:07











  • @BladeMight well I want it to be more user friendly

    – john snow
    Mar 8 at 11:08






  • 2





    Provide the html

    – Hemant Parashar
    Mar 8 at 11:09






  • 1





    Please provide the full html or a JSFiddle / Codepen example

    – Matt.Hamer5
    Mar 8 at 11:11






  • 1





    U have a proposition of how you want it to look like ? I don't know it others can help but I find it hard because You didnt say how your from has to look like

    – TaouBen
    Mar 8 at 11:19












  • 2





    doesn't look good, and I want it to look better - only you know what is good.

    – BladeMight
    Mar 8 at 11:07











  • @BladeMight well I want it to be more user friendly

    – john snow
    Mar 8 at 11:08






  • 2





    Provide the html

    – Hemant Parashar
    Mar 8 at 11:09






  • 1





    Please provide the full html or a JSFiddle / Codepen example

    – Matt.Hamer5
    Mar 8 at 11:11






  • 1





    U have a proposition of how you want it to look like ? I don't know it others can help but I find it hard because You didnt say how your from has to look like

    – TaouBen
    Mar 8 at 11:19







2




2





doesn't look good, and I want it to look better - only you know what is good.

– BladeMight
Mar 8 at 11:07





doesn't look good, and I want it to look better - only you know what is good.

– BladeMight
Mar 8 at 11:07













@BladeMight well I want it to be more user friendly

– john snow
Mar 8 at 11:08





@BladeMight well I want it to be more user friendly

– john snow
Mar 8 at 11:08




2




2





Provide the html

– Hemant Parashar
Mar 8 at 11:09





Provide the html

– Hemant Parashar
Mar 8 at 11:09




1




1





Please provide the full html or a JSFiddle / Codepen example

– Matt.Hamer5
Mar 8 at 11:11





Please provide the full html or a JSFiddle / Codepen example

– Matt.Hamer5
Mar 8 at 11:11




1




1





U have a proposition of how you want it to look like ? I don't know it others can help but I find it hard because You didnt say how your from has to look like

– TaouBen
Mar 8 at 11:19





U have a proposition of how you want it to look like ? I don't know it others can help but I find it hard because You didnt say how your from has to look like

– TaouBen
Mar 8 at 11:19












1 Answer
1






active

oldest

votes


















0














Based off the second image you posted about how you would like it to look I created a basic JSFiddle for you (as you didn't post the rendered html code I had to use random values).



Basically, each of your inputs for the form should be wrapped in a nice little container as follows:



<label class="input-container" for="forename">
<span class="label">First Name</span>
<input class="input" type="text" id="forename" placeholder="Your name..">
</label>


You would then use flex to display the label and input values next to each other. This will work for all input values - not just basic text ones.





#form 
width:800px;
.input-container
display:flex;
flex-direction:row;
align-items:center;
width:100%;
margin-bottom:1rem;
.label, .input
display:flex;
width:auto;

.label
font-size:87.5%;
padding-right:1rem;

.input
padding:.5rem;
font-size:100%;
flex-grow:1;
max-width:500px;







<div id="formDiv">
<form id="form">
<label class="input-container" for="forename">
<span class="label">First Name</span>
<input class="input" type="text" id="forename" placeholder="Your name..">
</label>
<label class="input-container" for="surname">
<span class="label">Last Name</span>
<input class="input" type="text" id="surname" placeholder="Your last name..">
</label>
</form>
</div>


https://jsfiddle.net/hz95Lkfu/






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061887%2fhtml-form-styling%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Based off the second image you posted about how you would like it to look I created a basic JSFiddle for you (as you didn't post the rendered html code I had to use random values).



    Basically, each of your inputs for the form should be wrapped in a nice little container as follows:



    <label class="input-container" for="forename">
    <span class="label">First Name</span>
    <input class="input" type="text" id="forename" placeholder="Your name..">
    </label>


    You would then use flex to display the label and input values next to each other. This will work for all input values - not just basic text ones.





    #form 
    width:800px;
    .input-container
    display:flex;
    flex-direction:row;
    align-items:center;
    width:100%;
    margin-bottom:1rem;
    .label, .input
    display:flex;
    width:auto;

    .label
    font-size:87.5%;
    padding-right:1rem;

    .input
    padding:.5rem;
    font-size:100%;
    flex-grow:1;
    max-width:500px;







    <div id="formDiv">
    <form id="form">
    <label class="input-container" for="forename">
    <span class="label">First Name</span>
    <input class="input" type="text" id="forename" placeholder="Your name..">
    </label>
    <label class="input-container" for="surname">
    <span class="label">Last Name</span>
    <input class="input" type="text" id="surname" placeholder="Your last name..">
    </label>
    </form>
    </div>


    https://jsfiddle.net/hz95Lkfu/






    share|improve this answer



























      0














      Based off the second image you posted about how you would like it to look I created a basic JSFiddle for you (as you didn't post the rendered html code I had to use random values).



      Basically, each of your inputs for the form should be wrapped in a nice little container as follows:



      <label class="input-container" for="forename">
      <span class="label">First Name</span>
      <input class="input" type="text" id="forename" placeholder="Your name..">
      </label>


      You would then use flex to display the label and input values next to each other. This will work for all input values - not just basic text ones.





      #form 
      width:800px;
      .input-container
      display:flex;
      flex-direction:row;
      align-items:center;
      width:100%;
      margin-bottom:1rem;
      .label, .input
      display:flex;
      width:auto;

      .label
      font-size:87.5%;
      padding-right:1rem;

      .input
      padding:.5rem;
      font-size:100%;
      flex-grow:1;
      max-width:500px;







      <div id="formDiv">
      <form id="form">
      <label class="input-container" for="forename">
      <span class="label">First Name</span>
      <input class="input" type="text" id="forename" placeholder="Your name..">
      </label>
      <label class="input-container" for="surname">
      <span class="label">Last Name</span>
      <input class="input" type="text" id="surname" placeholder="Your last name..">
      </label>
      </form>
      </div>


      https://jsfiddle.net/hz95Lkfu/






      share|improve this answer

























        0












        0








        0







        Based off the second image you posted about how you would like it to look I created a basic JSFiddle for you (as you didn't post the rendered html code I had to use random values).



        Basically, each of your inputs for the form should be wrapped in a nice little container as follows:



        <label class="input-container" for="forename">
        <span class="label">First Name</span>
        <input class="input" type="text" id="forename" placeholder="Your name..">
        </label>


        You would then use flex to display the label and input values next to each other. This will work for all input values - not just basic text ones.





        #form 
        width:800px;
        .input-container
        display:flex;
        flex-direction:row;
        align-items:center;
        width:100%;
        margin-bottom:1rem;
        .label, .input
        display:flex;
        width:auto;

        .label
        font-size:87.5%;
        padding-right:1rem;

        .input
        padding:.5rem;
        font-size:100%;
        flex-grow:1;
        max-width:500px;







        <div id="formDiv">
        <form id="form">
        <label class="input-container" for="forename">
        <span class="label">First Name</span>
        <input class="input" type="text" id="forename" placeholder="Your name..">
        </label>
        <label class="input-container" for="surname">
        <span class="label">Last Name</span>
        <input class="input" type="text" id="surname" placeholder="Your last name..">
        </label>
        </form>
        </div>


        https://jsfiddle.net/hz95Lkfu/






        share|improve this answer













        Based off the second image you posted about how you would like it to look I created a basic JSFiddle for you (as you didn't post the rendered html code I had to use random values).



        Basically, each of your inputs for the form should be wrapped in a nice little container as follows:



        <label class="input-container" for="forename">
        <span class="label">First Name</span>
        <input class="input" type="text" id="forename" placeholder="Your name..">
        </label>


        You would then use flex to display the label and input values next to each other. This will work for all input values - not just basic text ones.





        #form 
        width:800px;
        .input-container
        display:flex;
        flex-direction:row;
        align-items:center;
        width:100%;
        margin-bottom:1rem;
        .label, .input
        display:flex;
        width:auto;

        .label
        font-size:87.5%;
        padding-right:1rem;

        .input
        padding:.5rem;
        font-size:100%;
        flex-grow:1;
        max-width:500px;







        <div id="formDiv">
        <form id="form">
        <label class="input-container" for="forename">
        <span class="label">First Name</span>
        <input class="input" type="text" id="forename" placeholder="Your name..">
        </label>
        <label class="input-container" for="surname">
        <span class="label">Last Name</span>
        <input class="input" type="text" id="surname" placeholder="Your last name..">
        </label>
        </form>
        </div>


        https://jsfiddle.net/hz95Lkfu/







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 13:24









        Matt.Hamer5Matt.Hamer5

        167214




        167214





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061887%2fhtml-form-styling%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived