Sub topic 2
Building the Sign-up Form in HTML
Assume you know basic HTML and a little JavaScript. You also need to know that an email service provider receives and stores submitted addresses.
Build a short, useful form
A sign-up form should ask only for information needed to deliver its offer. The server must validate the email again because browser validation can be bypassed.
<form action="https://example.com/subscribe" method="post">
<label for="email">Email address</label>
<input type="email" id="email" name="email"
autocomplete="email" required>
<div style="position:absolute;left:-9999px"
aria-hidden="true">
<label for="website">Leave this field empty</label>
<input type="text" id="website" name="website"
tabindex="-1" autocomplete="off">
</div>
<label>
<input type="checkbox" name="consent"
value="yes" required>
I agree to receive the weekly newsletter and can
unsubscribe at any time.
</label>
<button type="submit">Subscribe</button>
</form>The label identifies each control. The type="email" value enables basic browser validation and suitable mobile keyboards. The honeypot field is a spam trap: normal visitors do not see or fill it, so the server can reject submissions where website has a value.
Accessibility and pop-up behavior
Use a real label, visible instructions, keyboard-accessible controls, and a clear error message. A pop-up should use the native dialog element. Opening it with showModal() supplies modal focus handling and lets visitors press Escape to close it.
Trigger, frequency, and device rules
A pop-up can appear after a visitor reads half the page, reaches a relevant section, or shows exit intent on a desktop device. Do not interrupt the first seconds of reading. Store a dismissal timestamp and suppress the prompt for several days.
On mobile, avoid full-screen interstitials that cover the main content, especially when visitors arrive from search. Use a compact inline form or a small, easily closed dialog. Target by page relevance, returning status, and device type. Measure conversions separately for each segment.
Exercise
A pop-up opens immediately on every page and covers the screen on phones. Name two changes that reduce harm.
Show answer
Delay it until a meaningful trigger, such as 50% scroll, and replace the mobile full-screen prompt with an inline form or compact dialog. Add a dismissal cooldown.