Editing HTML to add id=

  • Unknown's avatar

    I’d appreciate any insight anyone can offer.  In the past I have successfully inserted id=”xyx” into text using ‘edit in HTML’.  I use these to allow users to link to points within a page from another page and to allow users to move within a page.

    It seems when editing as HTML to install an id=”xyz” I am no longer allowed to do this. Previously, over a year ago, I created a couple of tags on a page:

    This is old code, I can edit it and it continues to work

    <h6 class=”wp-block-heading has-text-align-left” id=”y21″>2021</h6>

    But trying to install a new id like this

    <h6 class=”wp-block-heading has-text-align-left” id=”y23″>2023</h6>

    I always receive this message

    This block contains unexpected or invalid content.
    Attempt Block Recovery

    What is going on?  Thanks for an insight.

    The blog I need help with is: (visible only to logged in users)

  • Hi there,

    Although the block editor does include a code view option, it is intended for the use of block code (specifically) and it’s not recommended that you edit it to add HTML code directly, and it can render some blocks ineffective.

    Instead you can add your CSS classes to the block settings directly (under the advanced tab) as explained in this article:

    WP
    WordPress Editor » Add Additional CSS Classes to Blocks
    4 min read
    This guide explains how to use the Additional CSS Classes feature of the WordPress editor. How it Works ⚠️ It is recommended to have basic knowledge of CSS code to use this feature. Here’s how we can support you with CSS. Using the Advanced block setting, you can add a CSS class to your block, letting you write custom CSS to style the block as you wish. Additional CSS

    Hope that helps. Please let us know if you have any more questions.

  • Unknown's avatar

    This was helpful and allows me to do what I want. Thank you.

  • The topic ‘Editing HTML to add id=’ is closed to new replies.