Reputation: 67888
I was reading up about DOM and I saw this function DOMCharacterData::appendData
. It appends the string data to the character data. So in layman's terms, what is character data?
Upvotes: 1
Views: 126
Reputation: 44173
It is defined in non layman's terms in the standard here.
But more simply, character data is any text in the HTML, that isn't part of a tag. This is in contrast to tags, attributes etc. It can be just typed as text, or defined with a CDATA section in the html, or a comment etc.
Example html:
<tag attribute="value">This is character data</tag>
<a><![CDATA[This is also all character data]]></a>
<!-- even this comment is character data -->
In the code above "This is all character data" is character data, but the tag surrounding it isn't. The same goes for the CDATA section and the comment. One thing that often surprises people is that whitespace counts as character data.
Upvotes: 3
Reputation: 65126
Character data is plain, simple text. Things such as DOMText
and DOMComment
inherit from DOMCharacterData
because they contain text data.
Upvotes: 1