Utilizing wp_editor, I have implemented a front-end form on my WordPress website for users to post without accessing the admin section. Although it is functional, there is a concern that users may copy and paste content with inline styles that could disrupt the site's design.
To address this issue, I have enclosed all posts in a div
with the class clean
, which removes any potential inline styles. See the SCSS code snippet below:
.clean {
/*Prevents inline styles from overriding when pasted*/
* {
font-color: inherit !important;
font-family: inherit !important;
font-size: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
b, strong {
font-weight: bold !important;
}
p {
margin:0;
padding: .5em 0 !important;
-webkit-margin-before:0;
-webkit-margin-after:0;
}
}
Despite using !important
in the CSS, which is typically discouraged, I am seeking an alternative approach. Is it possible to achieve this in pure CSS?