It's the difference between printing, handwriting, and calligraphy.
This element, called nabebuta or keisankanmuri (), should be connected and vertical for more formal (printed) styles, and will normally be disconnected and 'diagonal' for calligraphic styles and many handwritten styles.
There is not right or wrong unless you are talking about a particular font style.
When practicing kanji early on, it is normally recommended to stick to a more 'standard' style, like Kyokashotai (thanks @drooze).