Question: how do you write 12 year old?
Answer: Rule 2: As long as a letter or numeral begins this unit modifier and it comes before a noun, it is correct to hyphenate. So, '12-year-old girl' or its oft-used shortened version, '12-y-o' is correct. Limit the number of hyphens you use to the modifier, though.