From the following verses:
Matthew 1:24-25 Then Joseph being raised from sleep did as the angel
of the Lord had bidden him, and took unto him his wife: And knew her
not till she had brought forth her firstborn son: and he called his
The phrase "knew her" is the Biblical way of saying "had sex with". Consider the following verses...
Genesis 38:26 And Judah acknowledged them, and said, She hath been
more righteous than I; because that I gave her not to Shelah my son.
And he knew her again no more.
JUDGES 19:25 But the men would not hearken to him: so the man took his
concubine, and brought her forth unto them; and they knew her, and
abused her all the night until the morning: and when the day began to
spring, they let her go.
So in other words, Joseph did not have intercourse with Mary until after Jesus was born.
That proves her virginity after marriage.
Her virginity before marriage is proven by her profession to the angel Gabriel...
LUKE 1:34 Then said Mary unto the angel, How shall this be, seeing I
know not a man?
...and also by Joseph's concern to take her as wife (he was afraid she was not a virgin). The angel Gabriel appeared to Joseph in a dream to dispel his fears (that she was indeed a virgin).
Matthew 1:19-20 Then Joseph her husband, being a just man, and not
willing to make her a publick example, was minded to put her away
privily. But while he thought on these things, behold, the angel of
the Lord appeared unto him in a dream, saying, Joseph, thou son of
David, fear not to take unto thee Mary thy wife: for that which is
conceived in her is of the Holy Ghost.