In the JSON Rich Text Editor (RTE), content is organized into block elements and inline elements. Understanding the distinction between these two types of elements is essential for content managers to create structured and well-formatted content.
This guide will walk you through what block and inline elements are, how they function, and when to use them, ensuring a smooth content authoring experience.
Block elements are used to structure the content into meaningful sections or blocks. These elements typically occupy the full width of the container they are placed in and are used to organize larger sections of content.
{
"type": "paragraph",
"children": [
{ "text": "This is a paragraph inside a block element." }
]
}Inline elements are used to format content within block elements. Unlike block elements, inline elements only occupy as much space as their content requires. They are placed within the flow of text, allowing content authors to apply styling and enhancements to parts of a sentence or paragraph.
{
"type": "text",
"marks": ["bold"],
"text": "This text is bold."
}Content authors can create rich content by combining block and inline elements. For example, you can insert a bolded word inside a paragraph or create a heading followed by a list. These elements work together to provide structure and formatting flexibility within your content.
Here’s a nested example demonstrating both block and inline elements:
{
"type": "paragraph",
"children": [
{
"text": "This is a ",
"marks": []
},
{
"text": "bold",
"marks": ["bold"]
},
{
"text": " word within a paragraph block.",
"marks": []
}
]
}Understanding block and inline elements will help you create well-structured and visually appealing content. Use block elements to organize content into meaningful sections and inline elements to format specific words or phrases within those sections.
For more details, explore our API reference on GitHub to understand how these elements work behind the scenes.