|
| 1 | +# MSC4159: Remove the deprecated name attribute on HTML anchor elements |
| 2 | + |
| 3 | +Some message types in `m.room.message`, such as `m.text`, permit including HTML in the event content. |
| 4 | +The spec [recommends] that clients limit the HTML they render to prevent attacks and provides a list |
| 5 | +of permitted HTML tags and attributes. In particular, it allows using the `name` attribute on `a` tags. |
| 6 | +This attribute is obsolete according to the [WHATWG HTML Living Standard] which is why this proposal |
| 7 | +attempts to remove it from the spec. |
| 8 | + |
| 9 | + |
| 10 | +## Proposal |
| 11 | + |
| 12 | +The `name` attribute was originally introduced to define targets for linking to specific parts of a |
| 13 | +webpage. As an example, including the named anchor `<a name="foo">bar</a>` on a site allows you to append |
| 14 | +the fragment `#foo` to the URL to cause your browser to scroll the anchor into view after loading the page. |
| 15 | + |
| 16 | +In modern versions of HTML this feature has been superseded by the `id` attribute which extends targeted |
| 17 | +linking to more than just `a` tags. As a result, the `name` attribute is marked deprecated in [MDN]. |
| 18 | + |
| 19 | +> Was required to define a possible target location in a page. In HTML 4.01, `id` and `name` could |
| 20 | +> both be used on `<a>`, as long as they had identical values. |
| 21 | +> |
| 22 | +> Note: Use the global attribute `id` instead. |
| 23 | +
|
| 24 | +Furthermore, it is also tracked as [obsolete but conforming] in WHATWG. |
| 25 | + |
| 26 | +> Authors should not specify the `name` attribute on `a` elements. If the attribute is present, its value |
| 27 | +> must not be the empty string and must neither be equal to the value of any of the IDs in the element's |
| 28 | +> tree other than the element's own ID, if any, nor be equal to the value of any of the other `name` |
| 29 | +> attributes on `a` elements in the element's tree. If this attribute is present and the element has an ID, |
| 30 | +> then the attribute's value must be equal to the element's ID. In earlier versions of the language, this |
| 31 | +> attribute was intended as a way to specify possible targets for fragments in URLs. The `id` attribute |
| 32 | +> should be used instead. |
| 33 | +
|
| 34 | +On top of the deprecation of the `name` attribute in HTML, it is unclear what this feature would ever have |
| 35 | +been used for in the context of Matrix. It appears highly undesirable to let events define targeted links |
| 36 | +into a client's UI, not least because the value of the `name` attribute would need to be unique on the |
| 37 | +entire page. Additionally, linking to specific events is already possible via [matrix.to URIs]. |
| 38 | + |
| 39 | +Therefore, the `name` attributed is removed from the list of permitted attributes on `a` tags without a |
| 40 | +replacement. |
| 41 | + |
| 42 | + |
| 43 | +## Potential issues |
| 44 | + |
| 45 | +Use cases that currently depend on the `name` attribute will be broken once the attribute is removed from |
| 46 | +the allowed list. No concrete use cases are known as of writing, however. |
| 47 | + |
| 48 | + |
| 49 | +## Alternatives |
| 50 | + |
| 51 | +None. |
| 52 | + |
| 53 | + |
| 54 | +## Security considerations |
| 55 | + |
| 56 | +None. |
| 57 | + |
| 58 | + |
| 59 | +## Unstable prefix |
| 60 | + |
| 61 | +None. |
| 62 | + |
| 63 | + |
| 64 | +## Dependencies |
| 65 | + |
| 66 | +None. |
| 67 | + |
| 68 | + |
| 69 | +[MDN]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#name |
| 70 | +[WHATWG HTML Living Standard]: https://html.spec.whatwg.org/ |
| 71 | +[matrix.to URIs]: https://spec.matrix.org/v1.10/appendices/#matrixto-navigation |
| 72 | +[obsolete but conforming]: https://html.spec.whatwg.org/#obsolete-but-conforming-features |
| 73 | +[recommends]: https://spec.matrix.org/v1.10/client-server-api/#mroommessage-msgtypes |
0 commit comments