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:

Link to comment
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
Link to comment
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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...