Whether we use “that” and “which” depends on whether the clause we introduce is restrictive or non-restrictive. A restrictive clause means that the information in the clause is necessary to understand the preceding noun and for a restrictive clause we use “that”.

We use “which” when the information in the clause is not necessary for understanding the noun in the sentence. That sort of a clause is a non-restrictive clause. There is one other important distinction between restrictive and non-restrictive clauses: commas are used to separate the non-restrictive clauses from the rest of the sentence.

Example 1: Ana’s book that has a shiny cover was a Christmas gift from her uncle.

In this sentence, we understand that Ana has multiple books, and it was important to distinguish the one with the shiny cover from her other books.

Example 2: Margaret’s house, which is painted green, has a back yard.

In this clause, the information about Margaret’s house being green is not necessary for understanding the noun in the sentence. Margaret only has one house, so the extra information does not help us identify it. Therefore, we use “which” and separate the non-restrictive clause with commas.