TD上的CSS不起作用。 HTM:Struts2主题=简单

时间:2012-12-12 00:23:37

标签: html struts2

为什么我的CSS不能正常工作?

<!--Struts2 log-in-->
<form id="login" name="login" action="/springtest/login.action" method="POST">  

    <tr>

        <td>
            UserName:<input type="text" name="userName" maxlength="20" value="" id="login_userName"/>
        </td>

        <td class="errorMessage">
            Username must not be blanks. 
        </td>
    <br>
    </tr>

    <tr>

        <td>
            PassWord:<input type="password" name="password" maxlength="20" id="login_password"/>
        </td>

        <td class="errorMessage">
            Password must not be blanks. 
        <td>
            <br>
    </tr>
    <tr> 
        <td>
            <input type="submit" id="login_0" value="Login"/>

        </td>
    </tr>
</form>

我的CSS用于类errorMessage就是这个。任何线索如何调试这个?我试过firedebug但是我只是新的...我也检查这个网站的答案可能有重叠?但你怎么知道呢?

.errorMessage {
color: red;
font-size: 0.8em;
} 

1 个答案:

答案 0 :(得分:0)

如果您的HTML有效(您没有<table>个标签,则<td>未关闭,<br />出现在不应该等的地方等等。)它会起作用 - { {3}}

<!--Struts2 log-in-->
<form id="login" name="login" action="/springtest/login.action" method="POST">  
    <table>
    <tr>
        <td>
            UserName: <input type="text" name="userName" maxlength="20" value="" id="login_userName "/>
        </td>
        <td class="errorMessage">
            Username must not be blanks. 
        </td>
    </tr>

    <tr>
        <td>
            PassWord: <input type="password" name="password" maxlength="20" id="login_password"/>
        </td>
        <td class="errorMessage">
            Password must not be blanks.
        </td>
    </tr>
    <tr> 
        <td colspan="2">
            <input type="submit" id="login_0" value="Login"/>
        </td>
    </tr>
    </table>
</form>