Well that depends, there is no difference in meaning but there is a difference in the way we use it. There are various ways to use both. However, we are going to look at how they work as relative pronouns.
To start with, we use “that” when we refer to people, animals, and things. We use “which” when we refer to animals and things.
If the clause is restrictive, you need to use the relative pronoun that, without it, the meaning would be unclear.
The car that he bought is very expensive.
Here we are being specific about the price of the car he bought. Without it, the sentence would lose its original meaning and purpose.
You would use the pronoun which when a clause is non-restrictive. Meaning that you are not being specific but instead you are adding extra information to a sentence. A comma usually accompanies this as it denotes a pause in speech and it always precedes which.
He bought a car, which is very expensive.
Here we are referring to him buying a car, not how expensive the car was. If we remove the clause, “which is very expensive,” it would have no effect on the sentence and still make sense. It serves to add further information only.
There is one exemption where it is possible to use “which” in a restrictive clause when preceded by a preposition.
The car in which I came was very expensive.
Correct use of that or which, depends on identifying the clause as restrictive or non-restrictive. If the clause is restrictive, use the relative pronoun that.
For clauses that are non-restrictive use the pronoun which. Do not forget about the exemption to the rule; you can use which in a restrictive clause when preceded by a preposition.
Both which and that can function as relative pronouns. That is only used in defining relative clauses while which can be used in both defining and non-defining clauses.
That can be used to refer to both objects and persons.
Which is not used for persons.
- The girl that you saw at the party is my sister. (defining clause)
- I’ve never read the book which is on the table. (defining clause)
- Pride and Prejudice, which was written by Jane Austen, is a great novel. (non-defining clause)
In a non-defining clause, which can refer to either a word or the whole meaning of the main clause:
- We love spending our holidays in my aunt’s house, which is by the seaside.
- One of the weakest jockeys came first in the horse race, which was a surprise to everyone.
In a defining clause, both that and which can occur:
- Please give me the book that my sister lent you last week.
- Please give me the book which my sister lent you last week.
However, only that (or the zero pronoun) should be used with reference to
1. indefinite pronouns or structures with indefinite pronouns:
- Everything that you do will be remembered.
- She cooked all the potatoes that were in the basket.
- I’ll tell you something that will shock you.
- I can’t find some of my T-shirts; I wish I could find the one that has yellow sleeves.
- The police examined each bag that was left in the locker.
2. superlative adjectives or phrases with superlative adjectives:
- This is the best film that I’ve ever seen.
- The most important thing that you must always keep in mind is honesty and hard work.
3. (phrases with) ordinal numbers:
- A book is the first that I would take to a desert island.
- The third excursion that we made in the mountains was a failure.
4. the only…, thing, etc.
- The only music that I really like is rock and roll.
- Tell me a thing that you never forget to do.
If there is a preposition before the pronoun, only which can be used:
- This is the house in which Beethoven was born.
- (This is the house that Beethoven was born in.)
- Do you remember the park opposite which we stayed in London?