There seems to much better ways by adding things in already written css rules rather than writing a new one.
e.g adjacent rule for zero-ing indent of paragraph. Why not just style whole paragraph with and id or class and add something in one of those…? Why write an adjacent.
Or are they just ammo rules in case they are needed.
You can be sure things like this were added for a reason.
Say you want margins on all paragraphs except the first on following a heading. Yes, you could put a class or id on the first paragraph. BUT… in today’s world, a lot of content is added by clients, so you don’t know which is going to be the first paragraph. But with the adjacent rule, it doesn’t matter, as you can just declare that any paragraph following a heading have no margin.
They can be very helpful. One of the examples I’m using them for is on sites where the content is Dynamic. So you basically create just one div, since the rest is generated in your output (repeat region), Let say that you want a top and bottom margin of 20px for all records except the first one. In that case those adjacent selectors become very handy since now you can indeed target the first record.
I will try to simplify it a bit. On a dynamic some content comes from the database. Lets say you would like to output a list with friends (first name & surname) On a static site the html would be something like this:
<div>
first name1 surename1
</div>
<div>
first name2 surename2
</div>
<div>
first name3 surename3
</div>
etc etc..
When this content on the other hand would come from the database, the structure would be completely diffent. First of all, do you receive the data using a query (MS SQL, mySql, Access etc.) in combination with a server side scripting language (PHP, Coldfusion…). When the data is received you output it using the server side scripting laguage. For example in Coldfusion (the language I’m using) The output for the above static example would look something like:
Depending on the query used this would output the list of your friends. As you can see is there only one physical div involved, which will be repeated with the output query.