diff --git a/src/core/title.js b/src/core/title.js index 912df79c35..9d2c2b7b4e 100644 --- a/src/core/title.js +++ b/src/core/title.js @@ -51,7 +51,18 @@ export function run(conf) { } // Decorate the spec title - if (!h1Elem.id) h1Elem.id = "title"; + if (!h1Elem.id) { + const existing = document.getElementById("title"); + if (existing && existing !== h1Elem) { + const msg = + 'Another element already uses `id="title"`. ' + + "The spec's `

` will use a different id to avoid a collision."; + showError(msg, name, { elements: [existing] }); + h1Elem.id = "document-title"; + } else { + h1Elem.id = "title"; + } + } h1Elem.classList.add("title"); setDocumentTitle(conf, h1Elem);