Spot on. The slot's length determines the maximum number of lanes. To add a bit to this, there can be physical and electrical differences. For example, you can have a full-length x16, but it's wired max x8. Length typically matches the electrical, but not always.Slots: The length of the slot determines the number of lanes (outward/return) x8 = 8 outward + 8 return.
This is the X16/X8/X4/X1
After that, there's nothing to stop you putting an X1 card in an X4/X8/X16 slot, or an X8 card in an X16 slot.
But you can't make the reverse physically impossible,
(although I've seen X8 slots wired in X4 (or the card, i don't remember)).
There are some 'open-ended' PCIe slots, too, that will take physically larger cards, but they are electrically limited to length. Sometimes, you see this in the smaller x1 and x4 slots.