Re: styles

On Tue, 26 Apr 2005, Evan Clarke wrote:

> I have been testing my site and there is a problem where the doctype
> does not allow styles to be set within the body tag.  Are styles only
> allowed to be set within the head tag or is there a way to keep the site
> w3c compliant while have styles set within the body tag?

Styles are allowed within the body tag:
<body style="font-family:Arial">

But you probably meant using a style element within the body _element_.
No, that's not allowed in any published DTD.

Usually the question arises in authoring environments where an
author cannot control what appears in the head element, only the body
element. The solution is to fix the environment.

Note that the really best way to use styles is to have a link element
(<link rel="stylesheet" type="text/css" href="...">) that refers to an
external style sheet, or several such elements. They need to appear in the
head element.

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

Received on Wednesday, 27 April 2005 05:31:07 UTC