It’s important to get the right size bike. Most bikes come in a range of sizes to fit your stature and bike makers will usually publish a rider’s height range which a bike of a specific size will fit.
You should feel comfortable seated on your bike and be able to put both feet flat on the ground when standing over the crossbar, without it touching you.
You’ll usually find more detailed frame dimensions listed too, which give you more details of how your bike will fit you. The most important are reach and stack, although they’re a bit complex to interpret.
In general, the higher the stack number (usually shown in cm or mm) the more upright your riding position will be. If you enjoy a 'taller' riding position then look for a more generous stack height. Equally, a shorter reach will put you closer to the bars, thus in a more upright position. For the most part, race bikes will feature a lower stack height than endurance models.
To make sure that your bike is set up correctly and to avoid the risk of injury from incorrect fit, it’s well worth getting a professional bike fit. A bike fit will cost some money, although sometimes a bike shop will offer one at a discount or free when you buy a bike, but will ensure that your saddle and bars are optimally placed for efficient riding. Consider a good fit an investment.