It is legal and safe. You can always check your markup at free validation service of w3 organisation: http://validator.w3.org/check
I would perfer to use CSS rather then using inside . It reduce the complexity of HTML code, it reduce the stress to the browser, by not rendering complex structure. Easy to grab using JavaScript.