- I prefer walking to riding
- I prefer walking (rather) than riding.
- I prefer to walk (rather) than to ride.
- I prefer books than TV. [BUZZER, NOT GRAMMATICAL]
Both those are acceptable. What the Cambridge Dictionary does not accept is:
I prefer x than y.
Conclusion: It is not to instead of than. The difference is the first is a noun (walking) whereas the second one is a verb phrase after to.
Please note: than means rather than.
On an official IELTS site:
would prefer + infinitive + rather than + base form of verb
= to want to do one thing more than another thing. (in the present or future) (“rather than” separates the 2 activities that we are
comparing. The activity before “rather than” is the one we want to do
the most.)
Examples:
I would prefer to go to New York rather than go to Los Angeles.
Jane:
I’d prefer to walk rather than get a taxi.
Please note: Those examples are for would prefer but they work for prefer alone.
Crown Academy of English
Here is what the founder of that site says about himself.
My name is Andrew and I am the founder of Crown Academy of English. I am British and a native English speaker. I was born in the city of Manchester in England.
I am a fully qualified English teacher. In 2003, I passed the Trinity CertTESOL qualification ( Certificate in Teaching English to Speakers of Other Languages), one of the most respected English teaching qualifications and recognised internationally by the British Council.
Please note: In speech, we often drop the rather with than so that rather than just becomes than.