Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict Content Security Policy (CSP) not possible due inline CSS #50417

Open
huubl opened this issue May 7, 2023 · 1 comment
Open

Strict Content Security Policy (CSP) not possible due inline CSS #50417

huubl opened this issue May 7, 2023 · 1 comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.

Comments

@huubl
Copy link
Contributor

huubl commented May 7, 2023

What problem does this address?

Right now it's very hard, nearly impossible, to add a strict Content Security Policy (CSP) when inline styles (style="..." attributes) are used (https://content-security-policy.com/examples/allow-inline-style/).

Besides this, there are other arguments for not using style attributes:

Specificity
Inline styles have the highest specificity and only !important rule can override this.

Principle of separation of content from presentation
See this issue: Move away from inline styles

What is your proposed solution?

Moving all CSS from style attributes to a <style> element or a CSS file. For example:

Change:
<p style="font-style:normal;font-weight:700">Lorum ipsum</p>

To something like this:
<p class="has-normal-font-style has-700-font-weight">Lorum ipsum</p>

@ramonjd ramonjd added [Type] Enhancement A suggestion for improvement. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json CSS Styling Related to editor and front end styles, CSS-specific issues. labels May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants