Let [Formula: see text] be a commutative ring, we say that [Formula: see text] has prime avoidance property, if [Formula: see text] for an ideal [Formula: see text] of [Formula: see text], then there exists [Formula: see text] such that [Formula: see text]. We exactly determine when [Formula: see text] has prime avoidance property. In particular, if [Formula: see text] has prime avoidance property, then [Formula: see text] is compact. For certain classical rings we show the converse holds (such as Bezout rings, [Formula: see text]-domains, zero-dimensional rings and [Formula: see text]). We give an example of a compact set [Formula: see text], where [Formula: see text] is a Prufer domain, which has not prime avoidance property. Finally, we show that if [Formula: see text] are valuation domains for a field [Formula: see text] and [Formula: see text] for some [Formula: see text], then there exists [Formula: see text] such that [Formula: see text].