Disabling the <font> Tag Using CSS

6 comments so far | Add yours Digg del.icio.us

Are you getting tired of clients using the deprecated <font> tag in their CMS? It’s easy enough to remove it using javascript or preferably server-side scripting, but you can also use CSS to disable the styles they define inside the font tag.

I found out when I was playing around with a better CSSReset File that standard browsers will override any style set in the HTML source if they are also defined as !important in the CSS file. In other words, if you set every CSS property as inherit !important in the font definition, it will override any attempt inside the HTML source and use the style previously defined in the CSS. It won’t take away the semantic error, but at least the client will not notice any visual effect and hopefully stop using it in time.

It’s a perfect companion to my newly updated CSSReset File.

So here it goes

This sort of bloated CSS code will not work in IE6/win, but in all other standard browsers I tested in. If the client attempt to write something like <font style="color: #aaa;">grey color<font> it will not work as they intended but instead inherit the default CSS style defined earlier. Feel free to post any glitches I missed.


font
	{
	color: inherit !important;
	margin: inherit !important;
	padding: inherit !important;
	font: inherit !important;
	text-decoration: inherit !important;
	border: inherit !important;
	background: inherit !important;
	bottom: inherit !important;
	top: inherit !important;
	left: inherit !important;
	right: inherit !important;
	position: inherit !important;
	clear: inherit !important;
	float: inherit !important;
	height: inherit !important;
	width: inherit !important;
	letter-spacing: inherit !important;
	text-transform: inherit !important;
	outline: inherit !important;
	overflow: inherit !important;
	display: inherit !important;
	visibility: inherit !important;
	text-indent: inherit !important;
	white-space: inherit !important;
	word-spacing: inherit !important;
	z-index: inherit !important;
	text-align: inherit !important;
	max-height: inherit !important;
	max-width: inherit !important;
	min-height: inherit !important;
	min-width: inherit !important;
	cursor: inherit !important;
	}

6 Responses so far. Add yours.

Permanent link At 3:42 pm on May 5th, 2007 , Tyrone wrote:

Nice, it’s a big list of properties required to kick the font tags butt, but worth it sometimes.
Hiding that in the UAstyles sheet from: http://leftjustified.net/journal/2004/10/19/global-ws-reset/
I bet there are some other deprecated tags this could be applied to.
Ignorance is bliss sometimes.

Can the form be fixed, forgetting to add the email brought an error and returning to the form all the comment got dumped. My first comments were better :(

Permanent link At 10:33 pm on May 6th, 2007 , David (author) wrote:

@Tyrone
Yes, there are. Setting the b { font-weight: normal } for example is a good thing since it should not be used in HTML 4.01. The same goes for <i>, <u>, <s> etc.

The other good thing about disabling the font tag like I did above is that old-school stuff like <font size=5> won’t work either. Phew.

Permanent link At 6:50 pm on June 28th, 2007 , Thomas wrote:

Thanks. This helps a little. To bad IE is so far behind. :)

Permanent link At 3:28 pm on June 20th, 2008 , programlama wrote:

css Cursor examples , Properties , Attribute - - http://css-lessons.ucoz.com/cursor-css-examples.htm

Permanent link At 11:11 pm on July 4th, 2008 , non reciprocal wrote:

HI i need your help i really want to create my own website/web page but i dont know how to go about doing it so can you please help me out

1 Trackbacks & Pings:

Permanent link Trackback at 9:57 am on May 13th, 2007 by Disabling the tag using CSS « Publiseringslosning:

[…] read more | digg story […]

This entry was posted on Friday, May 4th, 2007.

React

Categories

RSS Feeds

Bookmark

Translate

Both comments and pings are currently closed.