Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Have you used CSS like this before?

Featured Replies

Hi,

 

I browse a lot of websites and I always look at he source to see what is going on and how other ppl out ther build their sites.

 

Anyway to cut a long story short I came across the following CSS

 

.listB > li > a > img { border: solid 3px #e5e5e5; }
.listB > li > a > .overlay { left: 3px; right: 3px; bottom: 3px; padding: 5px; background: #000; }
.listB > li > a:hover > .overlay, .listB > li.on > a > .overlay { background-color: #f5a600; color: #000; }

 

I noticed the ">" and was wondering what it does?

 

If you style with CSS like this I would love to know what it does and why its being used.

 

Thanks

The > indicates that there should only be a match when an element is the direct child of another element. It might be easier to explain the differences with a bit of code.

<body>
<div>
 <div>
  <p>Hello</p>
 </div>
</div>
</body>

Here are four different lines of CSS and how they affect the output;

 

body > div > p { color: red;} = Hello (no match, color not applied)

body div p { color: red;} = Hello (it matches regardless of the second div before the p)

body div div p {color: red;} = Hello

body > div > div > p {color: red;} = Hello

Edited by Dcruize

  • Author

 

Thanks for the link, bookmarked!

 

The > indicates that there should only be a match when an element is the direct child of another element. It might be easier to explain the differences with a bit of code.

<body>
<div>
 <div>
  <p>Hello</p>
 </div>
</div>
</body>

Here are four different lines of CSS and how they affect the output;

 

body > div > p { color: red;} = Hello (no match, color not applied)

body div p { color: red;} = Hello (it matches regardless of the second div before the p)

body div div p {color: red;} = Hello

body > div > div > p {color: red;} = Hello

 

Brilliant explanation thank you!

There is a good article here on 30 of these selectors here:

 

http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/

 

There are plans to introduce more of these in the future. Which means they won't work in earlier IEs.

 

This may help with that though.

 

http://code.google.com/p/ie7-js/

  • Author

There is a good article here on 30 of these selectors here:

 

http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/

 

There are plans to introduce more of these in the future. Which means they won't work in earlier IEs.

 

This may help with that though.

 

http://code.google.com/p/ie7-js/

 

 

wow brilliant stuff, the tutsplus article went down well with my morning coffee. It also answered questions I am sure I would be asking in the future. Thanks for the links!

 

Ideally you should write your CSS with as little specificity as possible, to ease maintenance. Stay clear of child selectors if you can do the job with plain descendant selectors.

 

Thank you for the advice. I have been really lucky to get a job updating websites without having prior experience or knowledge. The coder that builds all the websites is always to specific with his selectors that its so hard to "recycle" the code from one page onto another page.

 

I am self thought(with lots of help from WDF) and always worked thinking about how to use as little css and html as possible and still achieve the best results. so "recycle recycle recycle"...

 

Thanks for your comments

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.