I know that long term capital gains taxes apply to assets held for more than 1 year. What happens if I buy 10 shares of stock X in May 2020, buy 2 shares of stock X in December 2020, and then sell 12 shares of stock X in June 2021? Are the first 10 shares taxes at long term while the 2 are taxed at short term capital gains rates? Ie is which specific share was purchased when factored in?
Yes, the shares are taxed as you describe. The term used to describe blocks of shares purchased is a "lot". In your example you have two lots, one with 10 shares and the other with 2.
If you were to sell less than 12 shares you could drill down and select which shares are actually sold, and from which lot. When selling shares you have three options: First in First Out (FIFO), Last in First Out (LIFO), or specific identification.
- FIFO: The shares are sold from oldest to newest.
- LIFO: The shares are sold from newest to oldest.
- Specific Identification: You pick which lots the stocks are sold from.
Generally you pick one of these within your brokerage account, although the default is usually FIFO. Different strategies might be better for different situations.