It is often difficult to determine whether you should use "that" or "which" in a sentence.
For example, do you say, "The black and white shark that swam above his head," or do you say, "The black and white shark which swam above his head?"
Here are two tips to help you get it right:
1. Identify the clause.
THAT is a restrictive clause.
A defining or restrictive clause gives us very important information about the words that follow. If the details are essential (i.e. restricted), then we use the word "that."
"The shark that has a scratch on his belly swam past."
This identifies a specific shark in the aquarium exhibit. It implies that there are a number of sharks, but the one that swam past has a scratch on his belly (important, restrictive information).
WHICH is a non-restrictive clause.
Non-restrictive clauses, if removed, will not change the meaning of the sentence.
Think of it as adding non-specific information.
"The shark, which is a cartilaginous fish, swam above his head."
It is an interesting detail that a shark is a particular type of fish, but it doesn't alter the meaning of the sentence (a shark swam above his head).
2. Do you need to use commas?
Non-restrictive clauses (where we use the word "which") are usually preceded and/or followed by a comma.
"There is a leak in the stingray exhibit, which is causing water damage."
Should commas be necessary, use "which" and not "that."
THAT - Information following the clause is essential to the meaning of the sentence.
WHICH - The information can be excluded.
WHICH - Commas are required.