I'm wondering which is the right way to attribute dialogue.

Is it "dialogue," xxx said.

or "dialogue," said xxx.

(xxx being the speaker.)

I normally use the latter, but I seem to be reading a lot of the former. Is this a grammar thing, or a style thing?