1

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 this? 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">
1
  • 1
    <td/> and <tr/> should be </td> and </tr>. Commented Jul 29, 2010 at 19:44

2 Answers 2

4

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

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

Comments

1

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.

2 Comments

Still have the same issue...the "top" style is still applied
See Gert G's answer; he caught the actual error. I still recommend strict for compatibility reasons though.

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.