Bitpicker explained enough. But in case you haven't heard, some words end in Ь and you can't know the gender of the word until you look it up. Like the word словарь (dictionary) is masculine. Мой словарь. But тетрадь (notebook) is feminine, making it Моя тетрадь. These rules apply all the time, with adjectives too, and all possessive pronouns except for его (his) and её (her) which never change regardless of word gender and case.

Also keep in mind, adjectives work in the same way.

Красивая женщина (a beautiful woman)
Красивое здание (a beautiful building)
Красивый город (a beautiful city)
Москва большая (Moscow is big)
Москва большой город (Moscow is a big city)