This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Stylesheets > August 2004 > Can you set CSS to override font tags?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Can you set CSS to override font tags?
|
|
| Nathan 2004-08-21, 11:15 pm |
| We have a content management system which allows our users to enter
html into pages on the site but they often just paste in from Word and
fill the site with word and html tags.
Our content management system will attempt to clean the code but
leaves some tags like the font tag untouched. Ideally the management
system would allow us to filter all tags we don't want out. But is
there anything in CSS which may also help to override font tags and
other html tags users inadvertently add to the site?
Thanks
Nathan
| |
| Stephen Poley 2004-08-21, 11:15 pm |
| On 16 Aug 2004 22:26:51 -0700, frnkln_nthn@yahoo.co.uk (Nathan) wrote:
>We have a content management system which allows our users to enter
>html into pages on the site but they often just paste in from Word and
>fill the site with word and html tags.
>
>Our content management system will attempt to clean the code but
>leaves some tags like the font tag untouched. Ideally the management
>system would allow us to filter all tags we don't want out. But is
>there anything in CSS which may also help to override font tags and
>other html tags users inadvertently add to the site?
If you check the CSS spec section 6.4.4, you'll see that there is
provision for allowing CSS to override FONT elements etc. However in
previous discussions I think it has been said that browsers are not very
reliable in this area. Faced with unpredictable versions of tag soup, I
think you'd be better off fixing the problem (i.e. the CMS) rather than
trying to patch over the symptoms. Failing this (because the supplier
has gone bust or refuses to fix the problem) you could try something
like a small PERL front-end which will strip all tags except for a few
in a "whitelist".
--
Stephen Poley
http://www.xs4all.nl/~sbpoley/webmatters/
| |
| Jukka K. Korpela 2004-08-21, 11:15 pm |
| Stephen Poley <sbpoleySpicedHamTrap@xs4all.nl> wrote:
> If you check the CSS spec section 6.4.4, you'll see that there is
> provision for allowing CSS to override FONT elements etc.
The way I see it, it says that CSS enabled browsers _must_ honor (in the
usual sense - there might be overriding rules in user style sheets, etc.)
CSS rules if they apply to FONT elements. But contrary to what people
seem to think fairly often, just setting font properties for the body
element for example won't do that. You need to use selectors that match
the font element (such as font, the name of the element, or *, the
universal selector) itself.
font { font-family: inherit;
font-size: inherit;
color: inherit;
font-weight: inherit; }
_should_ nullify the effect of font tags, by the specification. (The last
declaration is mostly theoretic: it nullifies the proprietary font-weight
attribute recognized by Netscape 4 [only, I think].)
> However in
> previous discussions I think it has been said that browsers are not
> very reliable in this area.
The main problem is that the value inherit is poorly supported, counting
by popularity of browsers. On Mozilla the above works fine, on IE not at
all. And there is in general no workaround - the value inherit has just
the meaning we want here, and there is no general substitute. For
the font size, however, we can use font-size: 100%. We could set
font-weight: normal, but that's not the same as inherit. More
importantly, we can set color: black but it then naturally makes the
color black even if the page's overall text color is different (e.g. due
to browser settings). And for font-family, what could we do?
> Faced with unpredictable versions of tag
> soup, I think you'd be better off fixing the problem (i.e. the CMS)
> rather than trying to patch over the symptoms.
Indeed. And allowing arbitrary tags (including browser-specific
monstrosities) creates unpredictable problems. So the positive approach
of permitted some repertoire of markup and throwing away the rest is
best.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|