Put your name and university in the right hand corner.
Put the date, and the office address on the left below this. (This helps to signal that you didn't just copy and paste the same cover letter that you sent to another firm).
Address the cover letter to the name of the university recruiter (if possible), the company's recruiting team, or their human capital group.
Sign off with sincerely and then your name.
Requirements
The requirements for your cover letter may differ depending on 1. the industry/role, 2. the firm, and 3. the way in which you’re applying.
I would generally suggest that, unless you have something important to explain, if the firm doesn’t require a cover letter don’t bother writing one (unless it's for a cold application). If they wanted to read one, they would make it a requirement. Submitting one won’t put your application over the top.
Suppose you are formally applying to a banking front-office position that requires a cover letter.
Your cover letter should be 300-500 words and consist of 4 paragraphs.
This should be 1-2 lines maximum - keep it concise. E.g. My name is John; I’m currently a third-year student studying Economics at the University of St Andrews. I’m writing to apply for Evercore's Financial Advisory Summer Internship.
Remember to use the same term that the firm uses for the name of the position e.g. Financial Advisory vs Investment Banking.
If you're low on space e.g. they ask you to write a 300 word cover letter, I would recommend cutting out this section since they can get all of this information from your online application.
In my opinion, this is the most difficult paragraph to write. Most people fill this paragraph with vague buzzwords and clichés. Don't say that you're interested in investment banking because you're passionate about the intersection between strategy and finance, or that it's fast-paced and intellectually stimulating. Be specific, and tell a story. Connect the dots between the job description and your background. What in your past experience (education, work experience etc) has led you to apply to this role?
To write a strong story, you must be very clear about what the role you're applying for actually is, and how it is different to other divisions. Make sure that you do your research before writing this paragraph.