A small piece of HTML can change what a visitor sees or how the browser understands a page. In this lesson, you will explore text, rcdata, rawtext, and script data contexts using a short example that you can inspect and change.
The Idea in Plain English
Some elements such as title and textarea parse their content as replaceable character data (RCDATA). Character references are recognized, but ordinary nested markup does not become child elements.
HTML supplies the structure; JavaScript supplies the behavior described here. If you remove the script, check what remains usable for visitors.
A Working Example
Read the sample once before copying it. Notice the element names and attribute values, then compare them with the explanation below.
<title>Books & Stories</title>
<textarea name="message" rows="3" cols="35">Write <b>bold</b> here.</textarea>
What Each Part Does
- The title gives the document a name in tabs and other browser surfaces.
- A textarea collects text across multiple lines.
- The b element draws attention to text without changing its importance.
- name identifies a field in submitted form data or a named metadata entry.
The browser treats angle-bracketed text differently inside a textarea than inside a normal div.
Keep the example small while learning. Once it behaves as expected, try it inside a larger page and make sure the URLs, files and surrounding HTML are correct.
Try It Yourself
Try this next: compare escaped text inside title and script. Then inspect the page and explain what changed.
Common Beginner Mistakes
- Expecting a bold tag written inside textarea to create bold text in the input control.
- Changing several parts of the example at once, making it difficult to see which part caused a different result.
- Choosing a tag only because its default appearance looks right, without checking whether it describes the content correctly.
Key Takeaways
- Some elements such as title and textarea parse their content as replaceable character data (RCDATA). Character references are recognized, but ordinary nested markup does not become child elements.
- The browser treats angle-bracketed text differently inside a textarea than inside a normal div.
- Test the markup in a browser, and check accessibility and real-world behavior where relevant.