This is just conceptual and largely off the top of my head, so take it for what it's worth. Also, I'm discussing taxable bonds with (original) maturities of more than one year that are not zeros. So this excludes T-bills and
STRIPS. In addition,
T-bills are non-covered, so unlike other bounds purchased since 20
14, their purchase price may not be reported to the IRS.
OID accretes (it is gradually added to the "natural" price of a bond). This portion of "appreciation" is treated as interest. (Think of a zero; all of the interest is reflected in the increase in price of the bond over time). Since this OID interest comes from the original issuer, here the Treasury, it is taxed the same way as if that interest had been part of the coupon. IOW, state tax exempt, federally taxable.
Market premium or discount is relative to the OID-adjusted price. You will likely sell at a higher or lower discount (or premium) than you got at time of purchase. For example, you might buy bonds with a total discount of $50, but sell them with no discount. This "gain" of $50 is treated differently depending on the YTW at which you bought the bond.
If you bought that bond with the expectation (i.e. YTW) that you would get $30 more at sale (instead of the $50 you got), then $30 is treated as ordinary (not Treasury) interest. After all, you purchased the bond for that
yield. Now you lucked out, rates dropped, and you got some extra (market) appreciation. That extra appreciation is taxed (fed and state) as a cap gain.
There's a de minimis rule: if the amount of market gain (i.e. excluding OID adjustments) is less than 0.25% x number of years you hold the bond, then the entire accretion (gain) is treated as a cap gain.
What if you bought a bond at a premium and sell it for less, or what if you even bought it at a discount but sold it at a bigger discount? That loss is used to reduce the amount of interest you receive. If you purchased a bond with a 3% coupon, but with a 2% premium, then you're effectively netting
1% in interest. This is reflected in how the bond is taxed.
I'm almost positive I've gotten something not exactly right here. Just trying to sketch the broad outlines.
There are some elections - basically how accretion is calculated (there are multiple methods) and whether one chooses to declare income annually or upon sale.
See Pub 550 generally. And look for explanatory pieces. The IRS is good at mechanics, not so good on explaining the concepts. I'm sure you can find better stuff than what I jotted down here. I haven't looked at this in depth in several years.