In the past, if you wanted to apply a wildly different style to more than one type of data in the same source, the only way to do this was to duplicate or subset a layer. With Rule Based Rendering, you now just have to create rules that are applied on-the-fly. This opens a huge door on cartographic possibilities with different features in the same layer not only having different colors but also different fill types, transparency, line type, and all manner of other customizations. Extending from categorized symbology, rules also allow for mixing and inheritance, allowing for intermediate categories or some shared properties and reducing the amount of work to create elegant symbology.
Rule Based Rendering is built-in to vector symbology. So, you'll need a good complicated vector layer to fully utilize its potential. A road layer is often a good use case, but for this example we'll go slightly simpler with busroutesall.shp.
busroutesall.shp layer.$length < 2000 (Do you want to see all the options? Then, open the filter tool with the … button). Name your rule and click on OK. Back in the main Style dialog, apply the rule to see the results in Canvas. Make sure to use the Test button to verify that your rule works:
$length > 2000 (don't forget to test this).
ROUTE name that contains a. The rule will look like: "Route" LIKE '%a'.
"ROUTE" % 2 = 0 is even-numbered).
Each rule is processed in the rendering order specified from top to bottom, the last rule being drawn last and, therefore, on top. The rules are added to any existing style that is already applied to feature. You can change the rendering order by changing the rule order or by applying a render order. The filters work just like attribute filters in the field calculator or the table search. All of the symbology options are available to vectors and can be applied to one or many rules. You can group rules by scale-rendering rules too.
There are way too many possible ways to use Rule Based Rendering than can be described here. You can create rendering groups that inherit rules from their parent and apply their own. Each feature given a unique ID could have a completely different look. The big improvement over using traditional single symbol, categorized, or graduated symbology is that you don't have to edit every possible group, and you can more easily stack rules, mixing and matching all the original methods.
There are some catches. Not everything you do with Rule Based Rendering is possible with web services; so, before you go too crazy, consider your output format and test your ideas before spending too much time on this.