Re: HTML Validator... Problem?

On Fri, 16 Aug 2002, David Newberry wrote:

> Anyway, this is the message it's reporting:
>
>     <p align="center"><hr width="65%" noshade size="1" color="000000"></p>
>                                                                         ^
>     Error: end tag for element "P" which is not open; try removing the end
> tag or check for improper nesting of elements
>
> Now, call me crazy, but it looks very definitely like I can close that P
> tag. When I look at the source tree, I see that it reports this:
>
>    <P>
>    </P>
>    <HR>
>    </HR>
>
> It seems that the validator is a little too eager and closes the P tag on
> its own before it gives me a chance. Am I correct that this is a bug, or
> did I do something stupid?

P cannot contain block-level elements such as HR.  Since the ending tag
for P is optional, the <HR> tag implies the end of the P.

If you wish to specify the alignment of an HR element, you can use <hr
align="center"> in HTML 4 Transitional.  However, the "align" attribute is
deprecated in favour of style sheets.  I generally find my HTML to be
nicer and easier to maintain if I don't use HR elements at all and instead
specify border-top or border-bottom in a Cascading Style Sheet.

-- 
Liam Quinn

Received on Friday, 16 August 2002 22:59:40 UTC