开发者

Nested CSS Problem

开发者 https://www.devze.com 2023-01-09 05:48 出处:网络
I have the following code: <table class=\"top\"> <tr> <td> <table class=\"errMsg\"><tr><td>Required field must not be blank </td></tr></table>

I have the following code:

<table class="top">
<tr>

    <td>
    <table class="errMsg"><tr><td>Required field must not be blank </td></tr></table>
<td/>
<tr/>
</table>

I am trying to style to the error message but the "top" style keeps applying:

.top td {
color:black;

}

.errmsg td {
color:red;
}

The error message comes out black...how can I fix th开发者_运维知识库is? Not sure if this matters but when I take out the dtd it works fine but it messes up the positioning.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


Class names are case sensitive, so errmsg is not the same as errMsg. Change <table class="errMsg"> to <table class="errmsg">.


I would use either a strict or transitional doctype. The xhtml doctype isn't well supported and my understanding is that it's basically going away.

for strict use:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

for transitional use:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

I almost always use strict as it offers the best browser support. Typically there are only a couple minor styles I need to set to fix some margins on certain tags.

Also, it's worth noting that when you completely remove the doctype line all browsers fall back to quirks mode, which is rarely a good thing. W3.org has a list of valid doctypes you might want to investigate.

0

精彩评论

暂无评论...
验证码 换一张
取 消