Coding CSS defensively
When working with CSS technologies, we may be in situations where not all browsers support a given property and we need to code around this partial support for the feature we're testing. To me, this is particularly important when creating examples to publish as part of a blog post or as standalone examples in Codepen. The idea is as follows: 1. Add a message to the example HTML and style it appropriately 2. Check if the browser supports the feature 1. If it does, hide the message 2. If the feature is not supported then make sure the message is displayed Using `:dir(rtl)` as an example, we add the following `div` with a warning class to the example. ```html
Feature not supported
Your browser doesn't support the :dir pseudo class