Unfortunately, this is not doable at the DNS level. You need a browser extension like uBlock Origin for that.
May I suggest to try Ad blocking apps? Such as Blokada Or Adguard.
If you're using Adguard then apply NextDNS TLS or HTTPs under Adguard DNS If you're using Blokada (free open source) Just enable ad protection & disable DNS to continue with NextDNS blocking.
Mohit I'm using ADGUARD and I love it. Can you help me with something? How do I add like you said NEXTDNS to my ADGUARD?
Bearded Anarchy nevermind, I figured it out. Just trying to see the difference between TLS and over https
Bearded Anarchy My answer of your question is already in my previous comment :)
If you're using Adguard on your Windows OS then open Adguard > Settings > DNS.
Scroll down and add DNS
If you're using TLS then type TLS:// and enter your nextdns TLS link mentioned in your nextdns.
If you're using https then use nextdns https:// link
Save it and then enable DNS and choose your saved nextdns.
Similarly you can do for Android or iPhone.
Here's the screenshot of my Android Adguard with nextdns.
I set RM to recognise/name my device on Nextdns server to monitor filters.
I hope you found this helpful.
Nice. Yeah I'm using all this on my Android. So I have it the same as you then, using the TLS. I appreciate the help.