CSS

Posts about Cascading Style Sheets.

Show The First N Items In A List With CSS

1st December 2020 - 2 minutes read time

A common design method is to use list elements to create the layout of a menu or a section on a page. This is all fine until the users come along and create lots of list items that mess up the layout of the page. In CSS it is possible to show only the first few items in the list so that your users can't mess up the layout.

To show only the first 2 items in a list use the adjacent sibling combinator to hide the third element and everything after that.

li + li + li {display: none;}

You can add as many li items to this list as you need to to ensure that the layout of your page works with the correct number of elements.

What Browser Supports What CSS Styles?

4th March 2013 - 2 minutes read time

Ever sat there and pondered which browsers support what css styles? If so I’d like to quickly introduce http://www.caniuse.com. This is a great tool and sometimes the quickest way to find answers to your questions. But what about W3Schools; I hear you say. W3Schools does have a comprehensive list of styles, complete with examples of how to use them and a list of properties that you can use. However, what I find W3Schools fails on is a comprehensive outline of browser support.

caniuse.com

caniuse.com provides you with a fool-proof table of browser support. It also outlines support for mobile browsers. Possibly one of the quieter features of caniuse.com is the ‘Known Issues’ tab underneath the table. So, ever tried to get rounded corners to work on a table with a background colour on the table header cells? These known issues can help you quickly debug your css.