o:content

The o:content global attribute chooses which property of the element becomes the exported file's body. Without it, the body depends on the element.

Syntax

html
<textarea hidden o:=notes.txt o:content=value>Remember the milk.</textarea>
<p o:=fragment.html o:content=innerHTML>Hello <b>world</b></p>

Value

property

The name of a DOM property of the element. The body is element[property], so any property works: value (a textarea's default text, or the value attribute of an input), innerHTML, textContent, innerText, id and so on. Numbers and booleans are served as text.

Default

Without the attribute, the body depends on the element:

ElementDefault body
<script>, <style>textContent
<template>innerHTML
<img> without o:content whose src starts with data:The decoded bytes (a binary file)
Every other element, including <img> with another srcouterHTML

Description

o:content works together with o:, and with worker:fs: a worker asset takes its body by the same rules. Setting o:content turns off the binary rule for <img src=data:…>: the named property is used instead of the decoded bytes.

Bodies are taken verbatim. The textContent of a script or style includes the line break after the start tag and the indentation before the end tag; nothing is trimmed.

Usage notes

Text fields

The value of a <textarea> differs between the two environments. Chrome decodes character references, so the playground exports Def & text <b> for a textarea that contains Def &amp; text &lt;b&gt;. RTEdge.net keeps them as written, Def &amp; text &lt;b&gt;. When the text can contain & or <, use textContent, which is entity-decoded in both.

Templates

On a <template>, o:content=textContent is empty in the playground, because the children live in the template's content, while RTEdge.net returns the text. o:content=outerHTML returns <template>…</template> without the template's attributes on RTEdge.net. Keep the default innerHTML for templates.

Misspelled properties

A property that does not exist gives no body. The playground does not serve such a file. When it shares its name with another export, both environments join the literal text undefined into the file, so check the spelling.

On deploy

Deploy strips o:content from the served HTML and from export bodies. The deployed source keeps it.

Cleaned copy on deploy

RTEdge.net reads outerHTML, innerHTML and other property values from a cleaned copy of the element: RTCode attributes are stripped, nested edge:remove elements become blank lines and nested edge:redact elements become comments. The playground reads them from the parsed element before any cleanup. Such bodies are therefore not byte-identical between the two.

Examples

A text field as a file

html
<textarea hidden o:=notes.txt o:content=value>Remember the milk.</textarea>
<iframe src=notes.txt></iframe>

The inner HTML of an element

html
<p o:=fragment.html o:content=innerHTML>Hello <b>world</b></p>
<iframe src=fragment.html></iframe>

Without o:content, /fragment.html would hold the whole <p> element. With it, the file holds only Hello <b>world</b>.

The value of an input

html
<input hidden o:=version.txt o:content=value value=1.4.2>
<iframe src=version.txt></iframe>

Specifications

Not part of any specification. o:content is an RTCode.io and RTEdge.net feature.

It builds on these standards:

Specification
DOM Standard

Availability

FeaturePlaygroundRTEdge.netNotes
o:content on exports and worker assetsYesYesAny property of the element.
Character references in a <textarea> valueDecodedAs writtenUse textContent for the same text in both.
o:content=textContent on a <template>EmptyYesKeep the default innerHTML.
Agent File Sync (Agent Folder Share)YesNoIn an export that holds the whole element, an agent's change to o:content is restored. Edit it in 📄.html. Chrome or Edge on desktop.

See also