简体   繁体   中英

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?

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.

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

不,CSS明确覆盖文档中的任何表示性标记。

You'll have to do some work to get it going,

The best option IMO is to style the classes for these elements in CSS and allow them to be overridden.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM