How do we write a CSS “block-level-style” within an inline style attribute tag?

StackOverflow https://stackoverflow.com/questions/8725028

  •  14-04-2021
  •  | 
  •  

Вопрос

Hi all I'm using Google Sites and I want to write a very simple CSS script in my page:

<style>p {background:#ccc;}</style>

However, Google removes all style tags. The solution they provide is to put our styles in an inline attribute as such:

<div style="...">

I've tried this but it doesn't work:

<div style="p {background:#ccc;}">

I was wondering how do we write a CSS "block-level-styles" within an inline style attribute tag?

Это было полезно?

Решение

You can't. Inline styles can only contain property-value declarations; they can't contain declaration blocks or selectors.

You would have to apply the background:#ccc inline style to all the p elements, unfortunately...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top