0

Is it possible to have html tables on a form input?

What I am trying to figure out is how to make the form input a small box, and not a box that stretches across the whole page. Hopefully this screenshot makes sense:

enter image description here

The code below trying to implement tables and tables rows (tr) isn't working well, any tips greatly appreciated.

<h1>GEB Research</h1>
<hr>
<fieldset>
  <table>

    <tr>
      <h2>Create Open ADR Event</h2>
    </tr>

    <tr>
      <form method="post" action="/trigger">
        <label>VEN ID:</label>
        <input type="text" name="VEN ID" value="" required><br>
        <tr>
          <label>Open ADR Payload Simple Signal:</label>
          <input type="number" name="Payload Signal" value="" required><br>
        </tr>

        <tr>
          <label for="starttime">Choose start date and time for event:</label>
          <input type="datetime-local" id="meeting-time" name="Event-Start" value="2020-07-12T19:30" min="2020-06-07T00:00" max="2024-06-14T00:00" required><br>
        </tr>

        <tr>
          <label>Event Duration in Minutes:</label>
          <input type="number" name="Minutes" value="" min="30" max="720" required><br>
          <small>Minimun requirement of 30 and maximum of 720 Minutes</small>
        </tr>

  </table>
</fieldset>
<input type="submit" value="Submit">
</form>

2 Answers 2

2

use display : inline-block;

form {
  display : inline-block;
}
<h1>GEB Research</h1>
<hr>
<form method="post" action="/trigger">
  <fieldset>
    <table>

      <tr>
        <h2>Create Open ADR Event</h2>
      </tr>

      <tr>
        <label>VEN ID:</label>
        <input type="text" name="VEN ID" value="" required><br>
        <tr>
          <label>Open ADR Payload Simple Signal:</label>
          <input type="number" name="Payload Signal" value="" required><br>
        </tr>

        <tr>
          <label for="starttime">Choose start date and time for event:</label>
          <input type="datetime-local" id="meeting-time" name="Event-Start" value="2020-07-12T19:30" min="2020-06-07T00:00" max="2024-06-14T00:00" required><br>
        </tr>

        <tr>
          <label>Event Duration in Minutes:</label>
          <input type="number" name="Minutes" value="" min="30" max="720" required><br>
          <small>Minimun requirement of 30 and maximum of 720 Minutes</small>
        </tr>
    </table>
  </fieldset>
  <input type="submit" value="Submit">
</form>

Sign up to request clarification or add additional context in comments.

Comments

1

Add width: fit-content to fieldset css. You should also fix your tags (<form> has interesting placement)

fieldset {
  width: fit-content;
}
<h1>GEB Research</h1>
<hr>
<form method="post" action="/trigger">
  <fieldset>
    <table>

      <tr>
        <h2>Create Open ADR Event</h2>
      </tr>

      <tr>
        <label>VEN ID:</label>
        <input type="text" name="VEN ID" value="" required><br>
        <tr>
          <label>Open ADR Payload Simple Signal:</label>
          <input type="number" name="Payload Signal" value="" required><br>
        </tr>

        <tr>
          <label for="starttime">Choose start date and time for event:</label>
          <input type="datetime-local" id="meeting-time" name="Event-Start" value="2020-07-12T19:30" min="2020-06-07T00:00" max="2024-06-14T00:00" required><br>
        </tr>

        <tr>
          <label>Event Duration in Minutes:</label>
          <input type="number" name="Minutes" value="" min="30" max="720" required><br>
          <small>Minimun requirement of 30 and maximum of 720 Minutes</small>
        </tr>
    </table>
  </fieldset>
  <input type="submit" value="Submit">
</form>

2 Comments

Any chance you could elaborate more on the You should also fix your tags (<form> has interesting placement)? Sorry learning web dev from starter level...
@HenryHub html tags should be closed before closing a parent's tag. In your post, your form tag is inside a tr but the /tr closes before the form. As you have a submit button, I moved the opening form tag to outside of the fieldset

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.