HTML complete: semantics, forms, media and SEO
HTML defines meaning, keyboard navigation, forms and the basis that search engines and assistive technologies consume.
Theory
Document and semantics
headcontains metadata, title, links, preload and scripts.bodycontains the visible document. A clear title and description improve navigation and presentation in results.header,nav,main,article,section,asideandfooterdescribe the purpose of each region. Browsers and assistive technologies use that structure to expose landmarks.divandspangroup content without adding meaning.- Block and inline describe formatting context behavior, which CSS can change. The semantics of the element do not change when modifying
display. abrowse and needhref;buttonexecutes an action. Modern browsers treattarget="_blank"asnoopener, but it is a good idea to declare therelpolicy explicitly;noreferreralso avoids sending the Referer header.
Forms and content
- Images need
altdepending on function.picture,srcsetandsizesallow formats and resolutions. Width and height reserve space and reduce CLS. - Video and audio support multiple
source,trackfor subtitles and controls. An iframe creates another context; restrict it withsandbox, permissions and trusted origin. - Form associates
labelwith control, usesnamefor submission, and takes advantage of native types. GET encodes to URL; POST sends body. The server validates all fields. - A
buttonwithin a form has typesubmitby default.type=buttonrepresents an auxiliary action and prevents accidental sending. The submit semantics also allow you to submit with Enter and run native validation.
Loading, SEO and accessibility
- A data table uses
caption,thead,tbody,thcells andscoperelationships. This structure associates every data cell with its headers. Tables used for layout communicate relationships that do not exist and make responsive design harder. brintroduces a break within the same content, such as an address or a poem.hrmarks a thematic shift between blocks. The visual space between elements belongs to margin, padding or gap in CSS.- Classic scripts with
deferdownload in parallel and execute after parsing, preserving the order.asyncruns when the download is finished and does not preserve the order.type="module"scripts are deferred by default. - Technical SEO includes HTML crawlable, canonical, robots, structured data, correct status, sitemap and rendering compatible with the content.
Example
<form (ngSubmit)="save()" [formGroup]="profileForm">
<label for="email">Correo</label>
<input id="email" type="email" autocomplete="email"
formControlName="email" aria-describedby="email-error">
<p id="email-error" role="alert">Ingresá un correo válido.</p>
<button type="submit">Guardar</button>
</form>Theme sources
Questions and answers
Label and attribute?See answerHide
The tag defines the element; The attribute configures information or behavior in its start tag. A property DOM represents the live state and may differ from the initial attribute.
id or class?See answerHide
id identifies an element within the document and is used for relationships, fragments and labels. class groups elements for styles or behavior.
How to create an accessible form?See answerHide
I associate labels, group options with fieldset/legend, use types and autocomplete, explain errors and move focus when the flow requires it.
ol or ul?See answerHide
ol communicates that the order modifies the meaning; ul groups elements without semantic sequence.
When do you use a link and when do you use a button?See answerHide
A link with href changes location and preserves native actions such as opening in another tab. A button executes an action in the interface. Choosing the right element brings keyboard, role and expectations without recreating them with JavaScript.
What does native form validation provide?See answerHide
Attributes such as required, type, min, max and pattern express constraints and allow feedback from the browser. The application can customize messages, but the server must repeat the validation because the client can modify it.
Semantic label?See answerHide
Element whose name communicates the role and structure of the navigator and assistive technologies.
head?See answerHide
Metadata and document resources, not visible main content.
alt?See answerHide
Textual alternative that depends on the function of the image; decorative use empty alt.
iframe sandbox?See answerHide
Restricts capabilities of the embedded document and opens with explicit tokens.
GET or POST in form?See answerHide
GET expresses query and leaves data in URL; POST sends body for an operation.
Submit default?See answerHide
A button inside a form uses submit if you don't declare type.
defer or async script?See answerHide
Defer preserves order and expects parsing; async runs when downloading.
How do you feel about this topic?