table 表单中的字段组

Fieldgroup inside of a table form

<fieldset style="width: 400px;">
        <legend><h2>Form Validation</h2></legend>
    <form>
        <table>
            <tr>
                <td>Name:</td>
                <td><input type="text" name="ime"></td>
            </tr>
            <tr>
                <td>Username</TD>
                <td><input type="text" name="username"></td>
            </tr>
        </table>
        <input type="submit" value="Submit" name="send">
    </form>
</fieldset>
        
    

我目前正在 table 中制作一个表格...这对我来说有点新鲜,因为我不知道该怎么做。以上是我试过的代码,我需要这样的代码。

如果有人能引导我走上正确的道路,我将不胜感激。

注:如上图所示,需要colspan为3,所以它们的宽度都可以相等。我只用 <form> 做了一个完美的,但我刚发现我们必须在 table...

内完成

最简单的方法是 colgroup - 在那里您可以指定 table 中任何列的 space 应该占多少。 对于您的示例,它将是这样的:(请注意,我没有感觉到所有需要的行)

<fieldset style="width: 400px;">
        <legend><h2>Form Validation</h2></legend>
    <form>
        <table>
        <colgroup>
        <col width="40%"/>
        <col width="60%"/>
        </colgroup>
            <tr>
                <td>Name:</td>
                <td><input type="text" name="ime"></td>
            </tr>
            <tr>
                <td>Username:</td>
                <td><input type="text" name="username"></td>
            </tr>
            <tr>
                <td>Password:</td>
                <td><input type="text" name="username"></td>
            </tr>
            <tr>
                <td>Re-type password:</td>
                <td><input type="text" name="username"></td>
            </tr>
             <tr>
                <td>Gender:</td>
                <td>
                <input type="radio" id="male" name="gender" />
                <label for="male">Male</label>
                <input type="radio" id="female" name="gender" />
                <label for="female">Female</label>
                <input type="radio" id="other" name="gender" />
                <label for="other">Other</label>
                </td>
            </tr>
            <tr>
                <td>Programming skills:</td>
                <td>
                <input type="checkbox" id="java"/>
                <label for="java">Java</label>
                 <input type="checkbox" id="ruby"/>
                <label for="ruby">Ruby</label>
                 <input type="checkbox" id="net"/>
                <label for="net">.Net</label>
                </td>
            </tr>
        </table>
        <input type="submit" value="Submit" name="send">
    </form>
</fieldset>