[w3c/editing] When should metadata-content elements like <style> be editable? (Issue #546)

dandclark created an issue (w3c/editing#546)

This was originally filed by @javifernandez at https://github.com/web-platform-tests/wpt/issues/59509; I'm opening it here in the hopes that it'll get more discussion in the EditingWG. See also https://dandclark.github.io/demos/editable-head.html. The `<title>` and `<style>` are fully editable in Chromium and Safari. In Firefox they are in a strange state: the `<title>` allows the user to place the caret like it's an editable field, but no changes can be made, and the `<style>` (at least on Windows) allows new characters to be typed but characters can't be deleted.

-----

The [delete-in-child-of-head.tentative.html](https://github.com/web-platform-tests/wpt/blob/master/editing/other/delete-in-child-of-head.tentative.html) tests propose a few cases where certain [metadata-content](https://html.spec.whatwg.org/multipage/dom.html#metadata-content-2) should be protected against merges / removal when they are part of a ```contenteditable```area. 

They have been added by Firefox in [bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1777905) as tentative, so it's understandable that even Firefox don't pass all of them. However, I have some doubts about when it's allowed and when not to consider ```style``` elements as editable, hence subject to editing commands, like delete or merge. For instance:

## Case 1

```
<!DOCTYPE html>
<pre contenteditable style="border: solid">
foo
<style contenteditable="false">pre { background: cyan }</style>
bar
</pre>
```

The 3 major browsers (Firefox, Safari and Chrome) allow the ```style```element to be deleted. This would allow the user to remove the format of the editable area, which seems like a legit use case.

## Case2 

```
<!DOCTYPE html>
<head contenteditable style="display: block; border: solid"></head>
<script>
document.head.textContent = "foo";
</script>
```

Only Firefox prevents the ```script``` to be removed.

So the question is, is the intention of the tests to imply that any metadata-content element should be considered non-editable in any circumstance  ? 


------------------------------------------------------------
In the original issue @masayuki-nakano [said](https://github.com/web-platform-tests/wpt/issues/59509#issuecomment-4553757436):

I didn't suggest any behavior with the test. Personally, I think the standards should make it impossible to edit the `<head>` elements with `contenteditable` nor `designMode` because e.g., deleting some elements like `<meta>` may change the document's meaning and modifying `<style>` changes the style of the document. If the `<style>` or `<script>` itself is an editing host, it may be useful in some (rare) cases, however, I don't think they should be merged especially with another element.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/546
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/editing/issues/546@github.com>

Received on Thursday, 23 July 2026 22:33:25 UTC