Although the Vatican is visited by hundreds of thousands of tourists and pilgrims each year, you should remember that it is a Holy place, and the dress code should reflect this during your visit:
No bare shoulders or midriffs
Like most churches in Italy, you will need to cover up shoulders and midriffs when entering the Basilica - this means no sleeveless shirts, no tank tops, and no sun dresses that are not appropriate. This includes men and older children, and anybody who is not up to standard will be turned away by security at the door. If you are wearing a dress or a singlet, a scarf or something similar will be sufficient for covering up your shoulders during your visit.
No knees showing
This has the same general rules as shoulders - you will turned away if you are wearing shorts or a dress that do not cover your knees. Women can wear tights or longer dresses to comply with these rules, and men could consider wearing pants that can be converted to shorts with zippers for example.
No hats indoors
You will definitely want hats and sunscreen if you are visiting the Vatican all day, but you will need to remove your hats when you go indoors.
Wear good walking shoes
You will spend nearly the whole day on your feet both walking around and waiting in lines during your visit to the Vatican so it is essential that you wear comfortable shoes.
As a general rule, you should remember that you are visiting a Holy place and that you should be dressed respectfully.
Clothing suitable for entry into the Vatican and in the churches of Rome requires that the shoulders and knees are always covered. Short-sleeved shirts can be used, but no tank tops that leave the arms and shoulders bare. Bringing a shawl with you can be a solution.
For skirts and trousers, these must cover the knees and therefore not be short. Shorts and short skirts are not welcome.
In the churches of Rome, and also in the Vatican, it is a good idea to take off your hat once you have entered it.