When setting the width of a cell with the "cell properties" icon this is added as ex. style="width: 20%" to the html of the td tag.

The core Filter module calls the filterXss() method of the \Drupal\editor\EditorXssFilter\Standard class.
https://git.drupalcode.org/project/drupal/-/blob/9.2.x/core/modules/edit...

This method filters out style as a dangerous tag

$dangerous_tags = ['script', 'style', 'link', 'embed', 'object'];

So the style attribute is always removed when the "Limit allowed HTML tags" option is enabled even if you allow <td style> in it.

The only option seems to disable "Limit allowed HTML tags" or use classes and a long workaround like in https://www.drupal.org/project/colorbutton/issues/2910028.

Comments

hansrossel created an issue. See original summary.

hansrossel’s picture

Issue summary: View changes
a.milkovsky’s picture

Thank you for reporting this. Maybe there is a way to change the functionality from style="width:20%" to width="20%".

hansrossel’s picture

Issue summary: View changes
hansrossel’s picture

The width attribute has been deprecated since HTML4 https://www.w3.org/TR/html401/struct/tables.html#edef-TH, so although it still works at this moment it could suddenly stop working in the future.

a.milkovsky’s picture

Alright. Then maybe https://www.w3.org/TR/html401/struct/tables.html#edef-COL is the right way.