Do you have the Use <span> instead of <legend> checkbox checked when you specify the settings for the legend?
There shouldn't be any files that are opened that would cause this issue.
Does this happen when you choose both other options for the legend (show legend in fieldset and Show in label header)?
Also did you choose a preset form/design type and edit from there or start from blank and made your own changes?