Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workaround for CSS reset overwriting deprecated HTML attributes (e.g. align, bgcolor)?

I have a website that gets updated through a WYSIWYG editor by people with very little HTML knowledge. The WYSIWYG exports table-based structure with old deprecated tags like "align" and "bgcolor" onto a site that is CSS driven so these attributes get overwritten.

For example, a black background is applied to a table in the WYSIWYG editor but once it goes live on the site, the background defaults back to none (default) because of the site's CSS reset.

Is there a way to account for these old tags the CSS is overwriting that I might not be seeing without getting rid of the reset CSS, creating additional CSS markup or upgrading the WYSIWYG tool?

like image 629
Moses Avatar asked Feb 07 '11 17:02

Moses


People also ask

Is it wrong to use important in CSS?

If you must use ! important in your CSS, comment your usage so future code maintainers know why the declaration was marked important and know not to override it. But definitely, don't use ! important when writing plugins or frameworks that other developers will need to incorporate without being able to control.

What will you use to style a single specific tag?

An inline CSS is used to apply a unique style to a single HTML element. An inline CSS uses the style attribute of an HTML element.


2 Answers

Ideally, you shouldn't be using a WYSIWYG editor which generates table-based layouts and deprecated attributes — it's just bad semantics.

I'd suggest upgrading to a better editor, such as TinyMCE, since there's no way you can make attribute styling override your CSS rules.

like image 58
Phil Powell Avatar answered Oct 29 '22 03:10

Phil Powell


You could use JavaScript to replace the bum-attributes with RegEx?

replace() - http://www.w3schools.com/jsref/jsref_replace.asp

RegEx - http://www.regular-expressions.info/tutorial.html

like image 44
Barrie Reader Avatar answered Oct 29 '22 02:10

Barrie Reader