Does an HSA contribution offset ordinary income first like the standard deduction?

The federal standard deduction offsets ordinary income, reducing your taxable income before capital gains & qualified income are "stacked" on top of your ordinary income in order to calculate final taxable income (taking the simplified view).  See this excellent explanation for more details https://www.fiphysician.com/cap[product key removed]-on-top-of-ordinary-income/

 

My question is, does the HSA deduction work the same way?  It's not accurate to just say "it reduces taxable income" because ordinary and qualified income are taxed at different rates so it's important to understand the distinction.  If after your standard deduction you have $6,000 of ordinary income subject to 10% taxes, and you contributed $6,000 to your HSA, does that HSA deduction then finish ofsetting your ordinary income, leaving you with only qualified income?  In that case you could have up to $83,550 of income from qualified income and/or long term capital gains and still pay zero taxes.  If the HSA deduction doesn't come in until the very end, AFTER qualified/ltcg is added in, then you will still pay taxes on that $6,000 of ordinary income.

 

Thanks for reading and thinking about this.