Perhaps an example would help.
Imagine you earn no income from other sources.
You buy shares for £5000 and sell them for £25000.
Your profit is £20000.
£8500 of this is tax free which leaves £11500 taxable gain.
So you pay 10% on £2090 of this
and 20% on the remaining £9410.
Total tax is thus £2091.
However now imagine you earn £25000 a year. (Ignore personal allowance here)
Again £8500 of your £20000 profit is tax free, which leaves £11500 taxable gain.
But as you already earned £25000 the £11500 is now "stuck on top" of this figure.
So you pay 20% on £7400 and 40% on £4100.
£25000 + £11500 = £36500
It's 40% above £32400 so you pay 40% on (£36500 - £32400) = £4100
This leaves £7400 which is taxed at 20% as you have already earned more than £2090 with your other income.
Sorry for a poor example. But at least it spares you the joys of indexation and taper relief.