Skip to content

Courses / HTML5 Mastery: Complete Beginner to Advanced Course / Elements, Tags, Attributes

677 people viewed this

Elements, Tags, Attributes

Fix:

<div><p>Hello</p></div>

Mistake 3: Forgetting Quotes Around Attribute Values

<input placeholder=Enter your name>

Fix:

<input placeholder="Enter your name">

Mistake 4: Using a Closing Tag for a Void Element

<img src="logo.png" alt="Logo"></img>

Fix:

<img src="logo.png" alt="Logo">

Mistake 5: Duplicating an Attribute

<p id="first" id="second">Hello</p>

Fix by choosing one identifier:

<p id="first">Hello</p>

Mistake 6: Reusing an ID

<p id="notice">First notice</p>
<p id="notice">Second notice</p>

Fix by using different IDs or a reusable class:

<p class="notice">First notice</p>
<p class="notice">Second notice</p>

Mistake 7: Putting a Block Container Inside a Paragraph

<p>
  Intro text
  <div>Container</div>
</p>

Fix by separating the paragraph and container into their own elements.

Mistake 8: Assuming a Slash Makes Any Element Self-Closing

<div />

In HTML, the slash does not close a non-void element in the XML sense. Use an explicit closing tag:

Rate this course

5.0 · 1 rating

Stars show on this course. Your written note stays private.

Your stars