0

I created a custom block using Strict HTML (and adding <div> and other tags to the allowed HTML). If I look at the frontend, it strips all the CSS classes like <div class="myclass">.

What do I have to do to create this block with all the CSS classes, and the custom HTML markup?

  • are you creating the block with the UI or programmatically? – reptilex Jun 28 '16 at 12:45
1

Default custom blocks in Drupal 8 use the Basic HTML text format. Using either Basic HTML or Restricted HTML will remove any class attributes.

You need to set your format to Full HTML to prevent Drupal from stripping out these attributes.

  • Thanks. I update my question. What is your advice? – meez Apr 23 '16 at 4:58
  • That question is off topic here; Drupal Answers sticks to questions about Drupal. What you're asking is a web design question. – Shawn Conn Apr 23 '16 at 5:18
  • No I don't ask how to style it. I want to know how I set it up in Drupal 8? Because when I make my own HTML format and add HTML I need it's strips all the CSS classes? – meez Apr 23 '16 at 5:21
  • As the answer states, setting the block Text Format to Full HTML prevents Drupal from stripping out class attributes. – Shawn Conn Apr 23 '16 at 5:31
  • Yes, this is correct: Strict HTML allows you to set which tags should be allowed, but not which attributes those tags should accept. class inside a HTML tag is an attribute. – kiamlaluno May 22 '16 at 5:56
0

You need to set your format to Full HTML to prevent Drupal from stripping out these attributes. I think it does not working when you backup data and deployed website .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.