Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

HTML global attributes #211

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/data/specifications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ html.spec.whatwg.org: 'WHATWG HTML Living Standard'
w3c.github.io/webappsec-cspee: 'Content Security Policy: Embedded Enforcement'
w3c.github.io/webappsec-feature-policy: 'Feature Policy'
wicg.github.io/priority-hints: 'Priority Hints'
w3c.github.io/contentEditable: 'ContentEditable'
1 change: 1 addition & 0 deletions content/html/HTML.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ link_lists:
- title: Reference
pages:
- "/content/html/reference/elements"
- "/content/html/reference/global_attributes"
---
**HTML** (HyperText Markup Language) is the most basic building block of the Web. It defines the meaning and structure of web content. Other technologies besides HTML are generally used to describe a web page's appearance/presentation ([CSS](/en-US/docs/Web/CSS)) or functionality/behavior ([JavaScript](/en-US/docs/Web/JavaScript)).

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: 'contenteditable attribute'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have short_title because it has a wordy title. To decide whether short_title is needed, imagine title in a sidebar, under a heading describing what sorts of things these are:

- Global attributes
    - contenteditable attribute
    - dir attribute
    - draggable attribute
...

versus:

- Global attributes
    - contenteditable
    - dir
    - draggable
...

mdn_url: /en-US/docs/Web/HTML/Global_attributes/contenteditable
interactive_example:
url: https://interactive-examples.mdn.mozilla.net/pages/tabbed/attribute-contenteditable.html
height: html-short
browser_compatibility: html.global_attributes.contenteditable
specifications:
- https://html.spec.whatwg.org/multipage/interaction.html#attr-contenteditable
- https://w3c.github.io/contentEditable/#contenteditable
examples:
- examples/using-contenteditable
recipe: html-global-attribute
---

## Short description

The `contenteditable` global attribute is an enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing.

## Values

The attribute must take one of the following values:

- `true` or the *empty string*, which indicates that the element must be editable;
- `false`, which indicates that the element must not be editable.

If this attribute is not set, its default value is inherited from its parent element.

## Usage notes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the recipe should include prose.overview after the interactive example, and we should use this "Usage notes" section for it (we've done something similar with the HTML elements, see #55).


This attribute is an enumerated one and not a Boolean one. This means that the explicit usage of one of the values `true`, `false` or the *empty string* is mandatory and that a shorthand like `<label contenteditable>Example Label</label>` is not allowed. The correct usage is `<label contenteditable="true">Example Label</label>`.

You can set the color used to draw the text insertion [caret](https://developer.mozilla.org/docs/Glossary/caret) with the CSS [`caret-color`](https://developer.mozilla.org/docs/Web/CSS/caret-color) property.

## See also

- [Making content editable](https://developer.mozilla.org/docs/Web/Guide/HTML/Editable_content)
- [`HTMLElement.contentEditable`](https://developer.mozilla.org/docs/Web/API/HTMLElement/contentEditable) and [`HTMLElement.isContentEditable`](https://developer.mozilla.org/docs/Web/API/HTMLElement/isContentEditable)
- The CSS [`caret-color`](https://developer.mozilla.org/docs/Web/CSS/caret-color) property
- `HTMLElement` [`input` event](https://developer.mozilla.org/docs/Web/API/HTMLElement/input_event) which also fires for `contenteditable` elements
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[SphinxKnight](/en-US/profiles/SphinxKnight),
[estelle](/en-US/profiles/estelle),
[mdnwebdocs-bot](/en-US/profiles/mdnwebdocs-bot),
[mfuji09](/en-US/profiles/mfuji09),
[wbamberg](/en-US/profiles/wbamberg),
[Wryn](/en-US/profiles/Wryn),
[jpreuss](/en-US/profiles/jpreuss),
[ExE-Boss](/en-US/profiles/ExE-Boss),
[genezx](/en-US/profiles/genezx),
[sideshowbarker](/en-US/profiles/sideshowbarker),
[DragMeToProgramming](/en-US/profiles/DragMeToProgramming),
[jpmedley](/en-US/profiles/jpmedley),
[Sheppy](/en-US/profiles/Sheppy),
[mfluehr](/en-US/profiles/mfluehr),
[chrisdavidmills](/en-US/profiles/chrisdavidmills),
[teoli](/en-US/profiles/teoli)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You can set the `contenteditable` attribute on nearly any HTML element to make it editable.

Here's a simple example which creates a `<div>` element whose contents the user can edit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div contenteditable="true">
This text can be edited by the user.
</div>
10 changes: 10 additions & 0 deletions content/html/reference/global_attributes/global_attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: HTML global attributes
mdn_url: /en-US/docs/Web/HTML/Global_attributes
recipe: landing-page
related_content: /content/related_content/html.yaml
link_lists:
- title: Index of HTML global attributes
directory: "/content/html/reference/global_attributes"
---
This page lists all the HTML global attributes, which are created using tags...
2 changes: 2 additions & 0 deletions content/related_content/html.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
children:
- title: Elements
directory: "/content/html/reference/elements"
- title: Global attributes
directory: "/content/html/reference/global_attributes"
10 changes: 10 additions & 0 deletions recipes/html-global-attribute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
related_content: /content/related_content/html.yaml
body:
- prose.short_description
- meta.interactive_example?
- prose.values
- prose.*
- meta.examples
- meta.specifications
- meta.browser_compatibility
- prose.see_also
1 change: 1 addition & 0 deletions scripts/build-json/build-page-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function buildPageJSON(docsPath) {
body = landingPage.buildLandingPageJSON(docsDirectory, data, content);
break;
case 'html-element':
case 'html-global-attribute':
case 'html-input-element': {
const cached = recipeCache[data.recipe];
let recipe;
Expand Down