Jump to content

Recommended Posts

Hello guys I have a question about CSS:
1.What is the different between these things:
div>p {background-color: yellow;}

div p {background-color: yellow;}

----------------------------------------------------------

2.And what is the different between these things:

:root {background-color: yellow;}

* {background-color: yellow;}

----------------------------------------------------------

3.And what is this:

::selection

----------------------------------------------------------

I will be happy if you answer me.

:wub:

Share this post


Link to post
Share on other sites

div>p {background-color: yellow;}  Will set paragraphs that's a direct child element of parent element div with background yellow https://www.w3schools.com/cssref/tryit.asp?filename=trycss_sel_element_gt it won't change paragraphs  nested within other child elements of the div parent.

div p {background-color: yellow;}  will change ALL child paragraphs within parent div whether they are nested or not. 

:root  will target the <html> element, it being the outermost containing element (root)

* universal selector:  meaning target ALL elements.

: single colon used for pseudo classes  such as :hover, :link, : visited

:: used for pseudo element ::after, ::before used to create content before or after a elements content, NOTE: older IE browsers use the single colon, but both can be used for modern better browsers than IE and Edge.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, dsonesuk said:

div>p {background-color: yellow;}  Will set paragraphs that's a direct child element of parent element div with background yellow https://www.w3schools.com/cssref/tryit.asp?filename=trycss_sel_element_gt it won't change paragraphs  nested within other child elements of the div parent.

div p {background-color: yellow;}  will change ALL child paragraphs within parent div whether they are nested or not. 

:root  will target the <html> element, it being the outermost containing element (root)

* universal selector:  meaning target ALL elements.

: single colon used for pseudo classes  such as :hover, :link, : visited

:: used for pseudo element ::after, ::before used to create content before or after a elements content, NOTE: older IE browsers use the single colon, but both can be used for modern better browsers than IE and Edge.

Thanks a lot sir

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...