• Resolved wperic

    (@wperic)


    I want to add a black border to an image. I clicked to edit the html for the image. The style statement for the image is
    style=”width:400px;height:auto” (with no semi-colon after auto).
    I edited that to
    style=”width:400px;height:auto;border-style:solid;border-width:3px;border-color:black;”/> (with and without semicolon at the end after black)
    WP rejects this. “Block contains unexpected or invalid content.”
    According to what I read at w3schools, this should be correct.
    I tried various iterations in the Additional CSS box, but WP rejected those as well.
    How do I put a border around this particular image on this particular page?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi
    I understand why this is confusing.
    Blocks do not only use HTML, their settings are also saved.
    So when you change the style attribute you must also change the style setting on the block itself.
    Otherwise, when there is a mismatch, the editor will consider the block invalid.

    The correct way to add the border is to do one of:
    – Use the border settings in the block sidebar
    – Add a CSS class in the Additional CSS class field and add your custom CSS to that class
    – Set the border as the default in theme.json.

    Thread Starter wperic

    (@wperic)

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Put border around an image’ is closed to new replies.