I was just on the website for Santa Maria del Fiore cathedral complex in Florence, and it states that appropriate attire is required, which includes no "bare legs" and no sandals. It also includes no bare shoulders, no hats, and no sunglasses, which are common.....but no "bare legs" is different than the usual requirement of no exposed knees. Likewise, most churches allow sandals.
I could certainly wear pants the day I plan to go see the Cathedral and Baptistry, but my plan was to only take sandals with me on my trip to Italy. Is that rule routinely enforced? I presume I could wear socks with my sandals (in the same way some women travel with a skirt or long scarf to wear over their shorts, for when they need to cover their knees when visiting churches).