Re: text-align

On Sun, 19 Nov 2006, Paul McLeod wrote:

> I have the following statement in my css style sheet:

It's called a "rule", to use the CSS term.

> H2 {
>
> text-align:center;
> font-size:12pt;
> color:black;
> font-family:arial,sans-serif,helvetica;
> vertical-align:middle;
> font-weight:bold;
> padding:0 10px;
> }
>
> It will validate as shown.

Yes, it will "validate", i.e. no syntax errors are detected. There's a 
(useful) warning, though: "You have no background-color with your color : 
H2". In my opinion, there _should_ be a warning about using the 
vertical-align property for a block element and about a value like 12pt 
for the font-size property. For example, warnings like those you get from 
the WDG's CSS checker http://www.htmlhelp.com/tools/csscheck/
"Warning: The vertical-align property only applies to inline and 
table-cell elements."
"Warning: Absolute length units should not generally be used on the Web, 
since the physical properties of the output medium are almost always 
unknown."

(There should be warnings about
   font-family:arial,sans-serif,helvetica
too. Since specific font names are case-sensitive in principle, arial and 
helvetica should probably be spelled Arial and Helvetica. Moreover, there 
is no point in specifying Helvetica after sans-serif, since the sans-serif 
font name is generic. If there is no match for it, there is surely no 
Helvetica font available in the system. - But checking CSS becomes more 
and more complex as we move from purely syntactic checks to such issues.)

> However, if I put the text-align statement anywhere else in the 
> statement it will not.

If I move it past the font-size declaration for example, the style sheet 
still "validates". You must be doing something non-obvious. Posting the 
URL of a CSS document (or an HTML document referring to a CSS document) is 
generally a good idea when reporting suspected problems.

It's also a good idea to use a little more spaces than formally required 
in CSS, for readability. While color:blue and color: blue are equivalent, 
most people probably find the latter more readable.

> Also, if I add a color statement it will not validate.

If I add a color declaration into your style sheet, it still "validates", 
though (quite adequately) with a warning like
"Redefinition of color : H2"

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

Received on Monday, 20 November 2006 08:09:40 UTC