Report an issue
Class

CKEDITOR.dtd

class singleton

Holds and object representation of the HTML DTD to be used by the editor in its internal operations.

Each element in the DTD is represented by a property in this object. Each property contains the list of elements that can be contained by the element. Text is represented by the # property.

Several special grouping properties are also available. Their names start with the $ character.

// Check if <div> can be contained in a <p> element.
alert( !!CKEDITOR.dtd[ 'p' ][ 'div' ] ); // false

// Check if <p> can be contained in a <div> element.
alert( !!CKEDITOR.dtd[ 'div' ][ 'p' ] ); // true

// Check if <p> is a block element.
alert( !!CKEDITOR.dtd.$block[ 'p' ] ); // true

It is also possible to add a new element to DTD. It will ensure it is handled correctly e.g. in terms of nesting or positioning.

For example, you can define a block element, which can be empty:

// Let's add a DTD for a new element <signature>
// and specify it can contain <p> and <img> elements:
CKEDITOR.dtd[ 'signature' ] = {
    p: 1,
    img: 1
};

 // Define <signature> as a block element.
CKEDITOR.dtd.$block[ 'signature' ] = 1;

// Allow <signature> element to be empty.
CKEDITOR.dtd.$empty[ 'signature' ] = 1;

Note: Editing the DTD for existing elements is also possible this way, but may cause an unexpected outcome and inconsistent editing behaviour, so it is not recommended.

Filtering

Properties

  • $block : Object

    List of block elements, like <p> or <div>.

  • $blockLimit : Object

    List of elements that contain other blocks, in which block-level operations should be limited, this property is not intended to be checked directly, use CKEDITOR.dom.elementPath.blockLimit instead.

    Some examples of editor behaviors that are impacted by block limits:

    • Enter key never split a block-limit element;
    • Style application is constraint by the block limit of the current selection.
    • Pasted html will be inserted into the block limit of the current selection.

    Note: As an exception <li> is not considered as a block limit, as it's generally used as a text block.

    Defaults to {article: 1, aside: 1, audio: 1, body: 1, caption: 1, details: 1, dir: 1, div: 1, dl: 1, fieldset: 1, figcaption: 1, figure: 1, footer: 1, form: 1, header: 1, hgroup: 1, main: 1, menu: 1, nav: 1, ol: 1, section: 1, table: 1, td: 1, th: 1, tr: 1, ul: 1, video: 1}

  • $cdata : Object

    List of elements that contain character data.

    Defaults to {script: 1, style: 1}

  • $editable : Object

    List of elements that are accepted as inline editing hosts.

    Defaults to {address: 1, article: 1, aside: 1, blockquote: 1, body: 1, details: 1, div: 1, fieldset: 1, figcaption: 1, footer: 1, form: 1, h1: 1, h2: 1, h3: 1, h4: 1, h5: 1, h6: 1, header: 1, hgroup: 1, main: 1, nav: 1, p: 1, pre: 1, section: 1}

  • $empty : Object

    List of empty (self-closing) elements, like <br> or <img>.

    Defaults to {area: 1, base: 1, basefont: 1, br: 1, col: 1, command: 1, dialog: 1, embed: 1, hr: 1, img: 1, input: 1, isindex: 1, keygen: 1, link: 1, meta: 1, param: 1, source: 1, track: 1, wbr: 1}

  • $inline : Object

    List of inline (<span> like) elements.

  • $intermediate : Object

    List of elements that are not to exist standalone that must live under it's parent element.

    Defaults to {caption: 1, colgroup: 1, dd: 1, dt: 1, figcaption: 1, legend: 1, li: 1, optgroup: 1, option: 1, rp: 1, rt: 1, summary: 1, tbody: 1, td: 1, tfoot: 1, th: 1, thead: 1, tr: 1}

  • $list : Object

    List of list root elements.

    Defaults to {dl: 1, ol: 1, ul: 1}

  • $listItem : Object

    List of list item elements, like <li> or <dd>.

    Defaults to {dd: 1, dt: 1, li: 1}

  • $nonBodyContent : Object

    List of elements which may live outside body.

  • $nonEditable : Object

    Elements that accept text nodes, but are not possible to edit into the browser.

    Defaults to {applet: 1, audio: 1, button: 1, embed: 1, iframe: 1, map: 1, object: 1, option: 1, param: 1, script: 1, textarea: 1, video: 1}

  • $object : Object

    Elements that are considered objects, therefore selected as a whole in the editor.

    Defaults to {applet: 1, audio: 1, button: 1, hr: 1, iframe: 1, img: 1, input: 1, object: 1, select: 1, table: 1, textarea: 1, video: 1}

  • $removeEmpty : Object

    List of elements that can be ignored if empty, like <b> or <span>.

    Defaults to {abbr: 1, acronym: 1, b: 1, bdi: 1, bdo: 1, big: 1, cite: 1, code: 1, del: 1, dfn: 1, em: 1, font: 1, i: 1, ins: 1, label: 1, kbd: 1, mark: 1, meter: 1, output: 1, q: 1, ruby: 1, s: 1, samp: 1, small: 1, span: 1, strike: 1, strong: 1, sub: 1, sup: 1, time: 1, tt: 1, u: 1, 'var': 1}

  • $tabIndex : Object

    List of elements that have tabindex set to zero by default.

    Defaults to {a: 1, area: 1, button: 1, input: 1, object: 1, select: 1, textarea: 1}

  • $tableContent : Object

    List of elements used inside the <table> element, like <tbody> or <td>.

    Defaults to {caption: 1, col: 1, colgroup: 1, tbody: 1, td: 1, tfoot: 1, th: 1, thead: 1, tr: 1}

  • $transparent : Object

    List of "transparent" elements. See W3C's definition of "transparent" element.

    Defaults to {a: 1, audio: 1, canvas: 1, del: 1, ins: 1, map: 1, noscript: 1, object: 1, video: 1}