When you buy stock under an employee stock purchase plan (ESPP), the income isn’t taxable at the time you buy it. You’ll recognize the income and pay tax on it when you sell the stock.
When you sell the stock, the income can be either ordinary or capital gain. The sale will qualify for capital gain treatment as long as the stock is held for both of these:
If you meet the holding-period requirements, your ordinary income from the sale depends on the option price. The option price:
Losses on the sale of ESPP stock are capital losses.
article credit: https://www.hrblock.com/
picture: Barron's/H&R Block