overexchange
overexchange

Reputation: 1

Is the content from style sheet part of DOM?

MDN says: Content specified in a stylesheet does not become part of the DOM.

Below is the code,

html:
A text where I need to <span class="ref">something</span>

css:
.ref::before {
  font-weight: bold;
  color: navy;
  content: "refer: ";
}

for which the DOM inspector shows the content under DOM:

enter image description here

How do I understand the above statement from MDN article?

Upvotes: 1

Views: 151

Answers (2)

somethinghere
somethinghere

Reputation: 17330

::before is a pseudo element - it is represented in the console, yes, but anything else interacting with the DOM does not detect it. You can't target a :before with javascript, for example. Don't confuse your inspector with the actual DOM.

CSS is not a document object, it is how such object should be displayed.

Upvotes: 4

Quentin
Quentin

Reputation: 943163

Is the content from style sheet part of DOM?

No

for which the DOM inspector shows the content under DOM

Don't read too much into that. It's a useful tool for debugging. It does not make the content part of the DOM. You cannot address it with the DOM API.

Upvotes: 5

Related Questions