The bid and ask prices are the best potential prices that buyers and sellers are willing to transact at. More specifically,
From an investor’s perspective:
The ask price is always higher than the bid price, and the difference between them is called bid/ask spread (or simply the spread). The size of the bid/ask spread is an important measure of a security’s liquidity. Highly liquid stocks, such as Apple (AAPL), have very “tight” (i.e., low) bid/ask spreads, while illiquid stocks tend to have wider (i.e., higher) bid/ask spreads.
Consider the following quote for $TSLA,
The bid/ask is “242.04 x 242.21,” meaning that you’ll have to pay 242.21 to buy $TSLA, but you’ll only receive 242.04 for selling $TSLA. The bid/ask spread at that point in time is \(242.21 - 242.04 = 0.17\).
On markets where there are market makers (“quote-driven market”), the bid/ask spread effectively compensates market makers for making a market in a stock. Effectively, a market maker may purchase stock from you (i.e., you’re the seller) at the bid, and then sell the stock to someone else (i.e., someone else is the buyer) at the ask. The ask is higher than the bid so that the market maker can capture a profit.
On an order-driven market, a transaction occurs when a potential buyer is wiling to pay the ask, or a potential seller is willing to accept the bid. Alternatively, a buyer and a seller may meet somewhere in-between to make the transaction happen.
Refer back to the $TSLA quote example above, you’ll notice an additional row labeled “Size.” The “bid size” is 100 (for US stocks, sizes displayed have been divided by 100), while the “ask size” is 200. This means that the buyer is willing to buy 100 shares of TSLA from you at the bid price of 242.04, and the seller is willing to sell 200 shares of TSLA to you at an ask price of 200. If you want to buy more than 200 shares of TSLA, the price may rise higher than the asking price. This is where market impact comes into play.
For details, refer to What are Bid/Ask Spread & Market Impact?