Skip to content

Allow ID attribute (HTML Anchor) on all blocks #21023

Closed

Description

@bobeaston

Essentialy, this is a request for reconsideration of issue #8124.

Currently (as of 5.4-RC3-47470) attempts to use id="foo" on any block type other than Heading or Group is either removed while converting to blocks or is flagged as invalid HTML when editing blocks. The attribute is useful for many other block types and is compliant HTML according to the latest W3C HTML specification, which says: "The class, id, and slot attributes may be specified on all HTML elements."

If we respect the W3C specification, all block types should support the HTML anchor attribute. The decision made in #8124 to "allow the id attribute on blocks that support anchor" conflicts with the W3C specification. WordPress should not be treating the attribute as invalid when converting from Classic to blocks.

Now, for the UI side of the question: From a practical point of view, most people will rarely need a UI element, like the one under Advanced in the current Heading block, in the editor to add an HTML Anchor. So, it might not be useful to provide the UI for some block types. From 20+ years of experience, I think it would be useful to have the UI element on these block types: Heading, Paragraph, Separator, Form, Table, Group ... and maybe Collections.

Activity

  1. added
    [Type] Enhancement
    on Apr 7, 2020
  2. paaljoachim commented on Nov 4, 2020

    @paaljoachim
    Contributor

    This feature has been added to Gutenberg.
    I will go ahead and close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions