Skip to content
Learn Netverks

Lesson

Step 24/58 41% through track

buttons

Buttons

Last reviewed May 28, 2026 Content v20260528
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~2 min
Level
advanced

This lesson

This lesson teaches Buttons—the ideas, syntax, and habits you need before moving on in HTML.

Without a solid grasp of Buttons, you will repeat mistakes in HTML exercises and on real pages or scripts.

You will apply Buttons in contexts like: Websites, hybrid apps, email templates, design systems, and CMS-driven content.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also use the HTML reference desk when you need tag or attribute lookup.

When intermediate lessons feel comfortable and you are ready for production-style trade-offs.

The <button> element represents an actionable control. Native buttons participate in focus order, respond to Space/Enter, and expose roles automatically.

Types

  • type="submit" (default inside forms): submits enclosing form.
  • type="reset": restores defaults—rarely desirable UX.
  • type="button": generic actions like toggles or dialogs.
<button type="button" aria-expanded="false">Menu</button>

Rendered output

Never fake buttons

  • <div onclick> lacks keyboard semantics unless you rebuild ARIA roles, tab focus, and key handlers.
  • Anchor tags styled as buttons confuse users expecting navigation—reserve a for hyperlinks.

Forms integration

Outside forms, default type still behaves as browsers specify—explicit type="button" avoids accidental submissions when templates move markup.

Icons inside buttons

Include visually hidden text or aria-label when only glyphs appear—icons alone rarely suffice.

What breaks real users

  • Submit buttons without explicit type—when markup moves between forms/pages, accidental form posts ship.
  • Disabled buttons lacking explanatory copy nearby—tell users why and how to fix eligibility.
  • Double submission: disabling button after click still needs optimistic UI + server confirmation to avoid duplicated charges.

Touch + pointer divergence

Taps don’t synthesize hover—don’t tuck critical controls behind hover-only affordances anchored to faux buttons.

Important interview questions and answers

  1. Q: What is the practical difference between `id` and `class`?
    A: `id` must be unique and is used for fragments/labeling; `class` is reusable for styling and behavior grouping.
  2. Q: Why is `defer` commonly preferred for scripts?
    A: It preserves HTML parsing, executes after parse, and avoids blocking rendering unlike classic synchronous scripts.
  3. Q: How do `srcset` and `sizes` work together?
    A: `srcset` provides candidate files and `sizes` tells expected rendered width so the browser can pick an optimal resource.

Pitfall: Use <button type="button"> inside forms unless submitting.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What confused you about this lesson?
  • How would you explain this to a teammate in 30 seconds?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump