These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:26 pm Advanced search

PCDATA and RCDATA - what is the difference?

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

PCDATA and RCDATA - what is the difference?

Postby rc » Mon Mar 17, 2008 11:10 am

Please someone explain the difference between PCDATA and RCDATA. Thanks a lot.
rc
<h6>
 
Posts: 3
Joined: Mon Mar 17, 2008 11:05 am

Postby zcorpan » Mon Mar 17, 2008 8:48 pm

In HTML, elements that are "PCDATA" are parsed as "normal" HTML -- that is, < and & are markup-significant charaters that start tags and entities, respectively. "RCDATA" elements are parsed as text with entities -- "<" does not start a tag (unless it's part of the element's end tag), and so RCDATA elements can't have element childen.

Example:

Code: Select all
<div><b>PCDATA</b></div>

<textarea><b>RCDATA</b></textarea>


(Notice how the text in the textarea becomes "<b>RCDATA</b>" instead of just "RCDATA".)

HTH
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby rc » Mon Mar 17, 2008 10:20 pm

Thank you. But then what is the difference between RCDATA and CDATA?
rc
<h6>
 
Posts: 3
Joined: Mon Mar 17, 2008 11:05 am

Postby zcorpan » Tue Mar 18, 2008 7:48 pm

CDATA can't have entities -- just text. e.g. "&auml;" is replaced with "ä" in PCDATA and (unless it's in an "escaped text span") in RCDATA, but is literally the characters "&auml;" in CDATA (and in RCDATA when it's in an "escaped text span").

Code: Select all
PCDATA:
<div>&auml;</div>

RCDATA:
<textarea>&auml;</textarea>

RCDATA with escaped text span:
<textarea><!--&auml;--></textarea>

CDATA:
<style> /* &auml; */ head, style { display:block } </style>
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby rc » Wed Mar 19, 2008 9:27 am

Thanks again. And one more question: what means "R" in "RCDATA"?
rc
<h6>
 
Posts: 3
Joined: Mon Mar 17, 2008 11:05 am

Postby zcorpan » Thu Mar 20, 2008 11:03 am

Replaced.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests