Yes, this is legal, although further explanation is necessary to understand why and to know what facts would result in a different conclusion.
A listing of a property with an offering price is an invitation to make an offer to purchase the property, rather than a true offer in a contract law sense. There is probably fine print at the website where the listing was provided that says so expressly, although this would be the default rule, even if it didn't.
The offer is the full written proposed purchase and sale agreement which contains details beyond the price such as deadlines for closing, financing approval outs, inspection and title defect outs, details as to personal property inclusions, etc.
Only when the full written purchase and sale agreement is signed by both parties or their authorized representatives is there ordinarily contract formation from offer and acceptance, although it is possible to imagine fact patterns that are exceptions to this general rule (e.g. auction sales, exchanges of detailed emails accepting without manual signatures, etc.). Normally, a purchase and sale contract will also include a tender of earnest money in an amount not specified in the listing, although this term is not legally required.
As another answer notes, there is a risk of discrimination liability depending upon the reasons for not accepting the offer made (which is not insubstantial if the seller has any information about the people who are offering to buy the property). This would be largely eliminated, however, if the seller had decided not to sell the property below a given price before having learned anything about the offers that had been made for the property. But this kind of money damages liability, even if possible, would rarely create a specifically enforceable contract to sell the real property.
There could conceivably be consumer protection act type liability, although having looked in the places where a statutory imposition of liability is most likely to be, it doesn't appear that this is illegal under those acts. Also, again, this kind of money damages liability, even if possible, would rarely create a specifically enforceable contract to sell the real property.
The most obvious consumer protection type suit would be to sue for failure to sell something as advertised, which is normally a deceptive trade practice under the California Civil Code § 1770(a)(9). But, sales of residence are exempt from the deceptive trade practices provisions of the California Civil Code. California Civil Code § 1754.
Likewise, this wouldn't be "bait and switch" advertising under California Business and Profession Code § 17500, et seq. and the related regulations (in the case of a "used" home where the decision is made by a non-dealer home seller), because the seller has no intent to sell substitute goods or services, at a higher price, to someone making an offer.
The California Business and Profession Code general provision related to false advertising, unlike the deceptive trade practices provisions of the California Civil Code, does not exclude real estate in general from its scope, and other provisions of that Code actually expressly provides for false advertising liability related to real estate that concerns statements about the real property itself, rather than the price and terms upon which the seller is willing to sell the real property.
It also wouldn't be common law fraud, because, as a matter of law, contrary to any logical arguments to the contrary, the price you are willing to sell something for is not a "fact" which is actionable for being falsely represented. A statement about a price you are willing to accept is never fraudulent as a matter of law (except when a statute provides otherwise). This exclusion exists to prevent fraud liability from arising out of ordinary price negotiations in commercial transactions.