+ 51

What are Pseudo-Elements and pseudo-class?

21st May 2018, 1:29 PM
Creative Coder
Creative Coder - avatar
14 Réponses
+ 29
In css you can have something like p:hover{ } Here hover is a pseudo class. It encodes the state of the element p::first-line{} Here first-line is a pseudo element. it is used to select a specific part of an element
21st May 2018, 2:11 PM
Max
Max - avatar
+ 27
PSEUDO CLASS:: A pseudo-class is used to define a special state of an element. For example, it can be used to: Style an element when a user mouses over it. Style visited and unvisited links differently. Style an element when it gets focus. PSEUDO ELEMENTS:: Pseudo-elements are very much like pseudo-classes, but they have differences. They are keywords, this time preceded by two colons (::), that can be added to the end of selectors to select a certain part of an element. 🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁 CHECK HERE VERY CLEAR && NICE EXPLANATION HERE::: 1.)https://www.w3schools.com/css/css_pseudo_elements.asp 2.)http://www.d.umn.edu/~lcarlson/csswork/selectors/pseudo_dif.html 3.)https://developer.mozilla.org/en-US/docs/Web/CSS/::first-line 4.)http://www.growingwiththeweb.com/2012/08/pseudo-classes-vs-pseudo-elements.html 5.)https://stackoverflow.com/questions/8069973/what-is-the-difference-between-a-pseudo-class-and-a-pseudo-element-in-css 6.)https://www.tutorialspoint.com/css/css_pseudo_elements.htm THANKS @ROYAL BB ☺
24th May 2018, 3:05 PM
Brijesh B
Brijesh B - avatar
+ 16
pseudo element.... I think i should say it is a keyword added to a selector in css that lets you style a specific part of an html page. For example, ::first-line can be used to change the font of the first line of a paragraph. and so on hope am making some senses.....
24th May 2018, 7:07 PM
Brymosoliu
Brymosoliu - avatar
+ 12
actually simply saying ..... pseudo elements are elements which is actually not available .... its a false element which is on page but it isn't.... in reality ....[ you can consider it as a ghost ] i hope you got it....😅
24th May 2018, 4:31 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 10
Psuedo Classes allow you to address an elements state. Psuedo elements allow to address it's parents , siblings and children. So what can you do with these if you are a CSS guru. Have a look at single div https://a.singlediv.com/
24th May 2018, 6:36 PM
Mike Choy
Mike Choy - avatar
+ 10
Pseudo elements.....are like a family. If you continue to search on the web or Sololearn or (duh, why didn't I mention it before or you might even know it ☺️) Sololearn CSS course you might get to know more about them.
25th May 2018, 4:04 AM
Calimari
Calimari - avatar
+ 8
A pseudo-class is a selector that assists in the selection of something that cannot be expressed by a simple selector, forexample :hover, :link, :visited, :active, :focus. A pseudo-element however allows us to create items that do not normally exist in the document tree, for example ::after, ::before, ::first-letter, ::first-line. Pseudo-classes select regular elements but under certain conditions, like when their position relative to siblings or when they’re under a particular state. Pseudo-elements effectively create new elements that are not specified in the markup of the document and can be manipulated much like a regular element. This introduces huge benefits for creating cool effects with minimal markup, also aiding significantly in keeping the presentation of the document out of the HTML and in CSS where it belongs.
24th May 2018, 11:26 PM
José Benaque
José Benaque - avatar
+ 8
psuedo elements are not really html elements but they are created and inserted at runtime. Since they are psuedo, you can not target them with javascript or jquery.
26th May 2018, 3:25 AM
Vikash Pal
Vikash Pal - avatar
+ 7
In addition to visiting Wenting Zhang's CSS video and website, perhaps this code will be interesting. It's one div + its pseudo elements, animated into position so you can get a sense how each element is used to construct a rotating yin-yang symbol: https://code.sololearn.com/WLZFqkui99gM/?ref=app
25th May 2018, 3:43 AM
Kirk Schafer
Kirk Schafer - avatar
+ 6
Pseudo classes have a colon before them, whereas pseudo elements have 2 before them.
25th May 2018, 2:45 AM
Siddharth
Siddharth - avatar
+ 6
For an excellent tutorial on pseudo elements and how they can be used, watch this YouTube video to make a wiggling mustache in ~7 minutes: "dotCSS 2016 - Wenting Zhang - Make CSS your secret super drawing tool" (16:51) https://www.youtube.com/watch?v=Y0_FMCji3iE Then visit her website, where she has published over FIVE HUNDRED complex icons using just ONE CSS element and its 'pseudo" elements to complete shapes. http://cssicon.space/ (website demo in video around 13 minutes) You can see how each icon is constructed by hovering over the various parts (tap a CSS section if on mobile), try the code on CodePen, and even animate between any two icons using the "Animate" panel.
25th May 2018, 3:27 AM
Kirk Schafer
Kirk Schafer - avatar
+ 5
Pseudo Classes:- When we want to change the style of a webpage on the basis of activity of user. For instance changing the color of a button when cursor is hovered over it. Pseudo Elements:- These are used to style specific parts of an element. For example, inserting content before or after the content of the element, or styling the first letter of an element.
25th May 2018, 1:46 PM
Ayush Agarwal
Ayush Agarwal - avatar
+ 5
CHIEF JV That shortURL is designed to generate advertising revenue for its owners, doesn't work, crashes proxy sessions, shows popups and redirects to trading sites. * This is not the place to exploit ad impressions. Don't post one of those again. On the off-chance your mobile posted on your behalf, you should scan for malware.
25th May 2018, 3:45 PM
Kirk Schafer
Kirk Schafer - avatar