1

我有下面的 HTML 页面,其中包含 1 个主表中的 2 2 个表。

    <%-- 
    Document   : P2
    Created on : Mar 7, 2013, 1:19:55 PM
    Author     : u0138039
--%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form name="form1" method="post" action="">
          <table width="722">
            <tr>
              <td width="334">
              <table width="255" >
                <tr>
                  <td width="128"><p>PARTS Updated&#13;</p></td>
                  <td width="111"><label for="PARTS_Updated"></label>
                    <select name="PARTS_Updated" id="PARTS_Updated" >
                      <option value=""></option>
                      <option value="N/A">N/A</option>
                    </select></td>
                </tr>
                <tr>
                  <td><p>TSI OK&#13;</p></td>
                  <td><label for="TSI_OK"></label>
                    <select name="TSI_OK" id="TSI_OK">
                      <option value="N/A">N/A</option>
                      <option value="TSI Query">TSI Query</option>
                    </select></td>
                </tr>
                <tr>
                  <td><p>Special Ins OK&#13;</p></td>
                  <td><label for="Special_Ins_OK"></label>
                    <select name="Special_Ins_OK" id="Special_Ins_OK">
                      <option value="N/A">N/A</option>
                      <option value="SI Query">SI Query</option>
                    </select></td>
                </tr>
              </table></td>
              <td width="376"><table width="279" align="center" height="44">
                <tr>
                  <td width="87"><p>Shipment ID&#13;</p></td>
                  <td width="97"><label for="Ship_ID"></label>
                  <input type="text" name="Ship_ID" id="Ship_ID"></td>
                </tr>
              </table></td>
            </tr>
          </table>
        </form>
        <h1>&nbsp;</h1>
    </body>
</html>

当我评论以下部分时

<%-- 
    Document   : P2
    Created on : Mar 7, 2013, 1:19:55 PM
    Author     : u0138039
--%>

我得到了我想要的表格,但是当我取消注释时,行空间正在改变,即它正在增加。请让我知道如何减少行空间并评论上述部分。

谢谢

4

1 回答 1

0

检查此代码:

<%-- Part 1 (Replace % with ! for HTML comment)
    Document   : P2
    Created on : Mar 7, 2013, 1:19:55 PM
    Author     : u0138039
-->
<!DOCTYPE html>
<%-- Part 2 (Replace % with ! for HTML comment)
   Document   : P2
   Created on : Mar 7, 2013, 1:19:55 PM
   Author     : u0138039
-->

<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
</head>
<body>
    <form name="form1" method="post" action="">
      <table width="722" border=1>
        <tr>
          <td width="334">
          <table width="255"  border=1>
            <tr>
              <td width="128"><p>PARTS Updated&#13;</p></td>
              <td width="111"><label for="PARTS_Updated"></label>
                <select name="PARTS_Updated" id="PARTS_Updated" >
                  <option value=""></option>
                  <option value="N/A">N/A</option>
                </select></td>
            </tr>
            <tr>
              <td><p>TSI OK&#13;</p></td>
              <td><label for="TSI_OK"></label>
                <select name="TSI_OK" id="TSI_OK">
                  <option value="N/A">N/A</option>
                  <option value="TSI Query">TSI Query</option>
                </select></td>
            </tr>
            <tr>
              <td><p>Special Ins OK&#13;</p></td>
              <td><label for="Special_Ins_OK"></label>
                <select name="Special_Ins_OK" id="Special_Ins_OK">
                  <option value="N/A">N/A</option>
                  <option value="SI Query">SI Query</option>
                </select></td>
            </tr>
          </table></td>
          <td width="376"><table width="279" align="center" height="44" border=1>
            <tr>
              <td width="87"><p>Shipment ID&#13;</p></td>
              <td width="97"><label for="Ship_ID"></label>
              <input type="text" name="Ship_ID" id="Ship_ID"></td>
            </tr>
          </table></td>
        </tr>
      </table>
    </form>
    <h1>&nbsp;</h1>
</body>
</html>

案例 1:如果您评论“Part1”和“Part2”。然后: 在此处输入图像描述

案例 2:如果您取消注释“Part1”并评论“Part2”。然后: 在此处输入图像描述

案例 3:如果您评论“Part1”并取消评论“Part2”。然后: 在此处输入图像描述

因为“DOCTYPE html”声明是对 Web 浏览器的指示,说明页面是用什么版本的 HTML 编写的。

在 Case2 中,第一行不是这个“DOCTYPE html”,因此网络浏览器无法知道 html 上的版本,因此无法格式化其余标签。

在 Case3 中,第一行是“DOCTYPE html”,因此网络浏览器能够知道 html 上的版本,因此它能够格式化其余标签。所以我们得到了格式化的表格。

于 2013-03-07T09:16:03.580 回答