Firstly you must understand that different types of web services are generally accessed over different port numbers, you could say there are lots of different "pipes" which different traffic is routed via. For instance unencrypted web traffic is on port 80, news servers are on port 119, secure web traffic is on port 443.
Simple shaping can be done by limiting the throughput on the ports you wish to shape thereby shaping that specific traffic.
However, things aren't that simple in real life and you can send any kind of traffic over any port you want if you know how to. This is where deep packet inspection comes in. What this does is analyses your traffic and looks for certain characteristics that are unique to different types of traffic, this traffic is then put into separate "baskets" and it is then shaped as it would be using the simple shaping method I mentioned earlier.
That's about as simple as I can explain it.