Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialUbo Town
3,227 Pointswhat does he mean when he says that Pseudo-Elements
"are phony elements that are not part of the DOM, like html are"
3 Answers
Brandon White
Full Stack JavaScript Techdegree Graduate 35,763 PointsHi Ubo,
A true explanation for the DOM is probably too large to type all on a message board, but it is essentially a structured map of a web page. It’s actually a data structure called a tree because it branches off from the top (or root element/node).
So if you were to think of a map of a family tree, the parents would be at the top, and then their children would be branched off from those parents, and if those children had children they would be branched off from that particular child of the original parents, etc, etc.
A DOM is like that. It stands for Document Object Model. The html element is at the root of the tree, then the head and body elements are its children. The div and h1 and main and img tags/elements are all descendants of the body element, while the meta and title tags/elements are descendants of the head elements. A model of that is created when you create a webpage and the browser uses it to display/paint your webpage the correct way.
A pseudo element is one that is not really there, but it acts like one. A pseudo element is created in CSS in the way that Lisa explained above, but what I think you’re probably confused about will make more sense like this...
When adding ::before
or ::after
to a selector (you are creating a “phony” element in the DOM). After you add before
or after
, you then give its rule a content property (and that property a value). Now the space before or after that selected element in the DOM can be treated as if an actual element were there. It’s used a lot with floats to do something called a clearfix.
Here an article on pseudo elements: https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
Ubo Town
3,227 Pointsi understood what pseudo-elements are. What I would like to know is this:
pseudo-elements are phony elements that are not part of the DOM, like html are. what are phony elements that are not part of the DOM. What is the dom?
Ubo Town
3,227 PointsWow! what an amazing explanation, thank you so much!!!
LISA G SANDERS
12,291 PointsLISA G SANDERS
12,291 PointsPseudo-Elements is a style that lets you select a particular part(s) of an element(s), ::first-line and change the font of a first letter of a paragraph. You can change the color or letter from lower to uppercase.