Extra Ecclesiam nulla salus - Outside the Church there is no salvation. All salvation comes from Christ the head through the Church His body. The Church is necessary for salvation.
Section 838 of the Catechism says the following:
"The Church knows that she is joined in many ways to the baptized who are honored by the name of Christian, but do not profess the Catholic faith in its entirety or have not preserved unity or communion under the successor of Peter." Those "who believe in Christ and have been properly baptized are put in a certain, although imperfect, communion with the Catholic Church." With the Orthodox Churches, this communion is so profound "that it lacks little to attain the fullness that would permit a common celebration of the Lord's Eucharist."
(A proper baptism means baptizing one who believes - the faith of the parents in the case of an infant - using the trinitarian formula: In the name of the Father, and of the Son, and of the Holy Spirit.)
The Compendium puts it like this:
171. What is the meaning of the affirmation “Outside the Church there is no salvation”?
This means that all salvation comes from Christ, the Head, through the Church which is his body. Hence they cannot be saved who, knowing the Church as founded by Christ and necessary for salvation, would refuse to enter her or remain in her. At the same time, thanks to Christ and to his Church, those who through no fault of their own do not know the Gospel of Christ and his Church but sincerely seek God and, moved by grace, try to do his will as it is known through the dictates of conscience can attain eternal salvation.