You are asked to add a second phone number to a contact section. It sounds like a small content edit. Then you open the markup: several nested containers, repeated classes, and a label whose connection to the existing number is not immediately clear.
Which pieces belong together? Which wrapper controls the layout? If you copy the block, will you duplicate an ID or bring along behavior intended for only one element?
None of those questions proves the implementation is wrong. The structure may support a layout, a script, or an editing-system requirement. But before changing it safely, someone has to reconstruct its intent.
Maintainable HTML makes that reconstruction easier. Appropriate elements, understandable grouping, and deliberate references help the next person see what the content means and what else depends on it. The goal is not the fewest lines of markup. It is enough clarity to make ordinary changes with proportionate review.
Understand the Edit Before Copying Markup
Start with the content question: what is the second phone number for?
If one number handles general inquiries and the other handles appointment changes, that distinction belongs in the visible content. Position alone—such as “the number on the right”—is a fragile explanation. A narrow layout may place the numbers vertically, and someone listening to the page needs the distinction too.
Next, inspect the existing implementation:
- Find the visible number and its telephone-link destination, if it has one.
- Identify the group containing the number and its description.
- Check whether its containers or classes participate in layout or behavior.
- Look for an ID that would need different treatment if the block were copied.
- Determine whether the markup comes from page content, a shared template, or another generated source.
The following illustrative structure uses fictional US phone numbers. It shows the intended content relationships, not a drop-in replacement for an unknown contact component:
<section class="contact-details">
<h2>Contact by phone</h2>
<dl>
<dt>General inquiries</dt>
<dd><a href="tel:+12025550101">(202) 555-0101</a></dd>
<dt>Appointment changes</dt>
<dd><a href="tel:+12025550102">(202) 555-0102</a></dd>
</dl>
</section>
A description list is appropriate here because the content consists of name–value pairs: each contact purpose is followed by its number. A maintainer can see which description belongs with which value and how another pair would fit.
The visible numbers and the tel: destinations agree. There are no IDs to duplicate in this example. The contact-details class provides a reusable hook, but its name alone cannot tell us whether a particular project uses it for styling, scripting, or both.
This structure does not settle every question. Its heading level must fit the surrounding document, its presentation needs review, and its numbers still require confirmation. What it makes clearer is the content relationship being extended.
Choose Elements That Reveal Purpose
Element choice helps a maintainer answer a basic question: what is this part of the page supposed to do?
In the contact example, an anchor with a tel: destination expresses a telephone link. The browser and device determine how that link is handled. A generic element with a click handler would require more investigation to discover the destination and assess its keyboard behavior.
The same distinction matters elsewhere:
- A link identifies a destination, such as a contact page or a section within the current page.
- A button performs an action, such as opening a contact-options panel. For a non-submit button, an explicit
type="button"avoids unintended form submission if it is placed inside a form. - A heading identifies the subject of the content that follows, rather than merely requesting large text.
- A list expresses a collection of related items, making additions easier to recognize as part of the same pattern.
Native elements do not eliminate implementation work. A button that opens a panel still needs appropriate behavior and state handling. They do, however, communicate a starting point that a maintainer does not have to rediscover entirely through CSS and JavaScript.
Clear wording remains necessary. A suitable element with an ambiguous label still leaves questions unanswered. Semantic HTML foundations provides the broader element-choice guidance; the maintenance benefit is that purpose becomes more visible in the source.
Keep Grouping Understandable
A useful container can make a change safer. It may keep a heading and its content together, establish a layout boundary, or provide a stable integration point for an editor.
The question is not “Can this wrapper be deleted?” It is “What responsibility does this wrapper have?”
A div may be entirely appropriate around contact details when the grouping exists for layout and no more specific element fits. A headed section, as in the example, expresses a thematic section. Neither choice should be made solely to reduce nesting or satisfy a preference for particular tag names. See when to use the HTML div element for that distinction.
Before simplifying a group, check whether it:
- Defines a grid or flex layout whose direct children matter.
- Provides spacing, positioning, or a responsive layout boundary.
- Acts as a script target or an editing-system boundary.
- Keeps content together that should move as a unit.
Consistent indentation makes those relationships easier for people to inspect. It does not create semantic relationships by itself. Those come from the elements, their actual nesting, and applicable attributes.
Make the correction in the source that owns it
When a CMS generates the contact block, distinguish the rendered HTML from its editable source. A browser inspection can reveal what reached the page, but a change made in developer tools is temporary.
If a shared template produces the same unclear structure on several pages, the durable correction may belong in that template. If the phone number is an editable content field, changing the template’s hard-coded output instead may bypass the intended workflow. Finding the owner of the markup is part of understanding the markup.
Preserve Relationships When Content Moves
Now consider a second small task: move the phone section under an existing “Visit and contact” section.
If “Visit and contact” is an h2 and the phone section becomes its subsection, “Contact by phone” would ordinarily become an h3. If the two sections remain peers, both may remain h2 headings. The correct choice follows the document hierarchy, not the desired font size.
Move the heading and its related content together. Then read the surrounding content in source order. Does the new sequence still explain where the reader is and which information belongs together?
CSS can change visual placement without changing the underlying reading sequence or, ordinarily, the keyboard focus sequence. A move that looks sensible on a wide screen may leave a confusing order in the document. The distinction between source order and visual order matters whenever content is rearranged.
Other relationships may need separate checks:
- A fragment link such as
href="#phone-contact"depends on a matching ID at its destination. - A form label using
fordepends on the matching ID of its labelable control. - An
aria-describedbyattribute identifies the element or elements providing a description through their IDs.
Moving referenced content does not automatically break an ID-based association if the references remain valid in the same document. Copying it, deleting it, or changing its ID can. Review the actual relationship rather than assuming that visual proximity establishes—or preserves—it.
Use IDs and Classes Deliberately
An ID identifies a particular element and must be unique within its element tree—for ordinary page markup, within the document. A class is reusable across elements. Both can become dependencies beyond their immediate appearance.
For the phone-number edit, this means a copied ID requires attention. If the original section has id="phone-contact", do not give a second section the same ID. First determine whether another identifier is needed at all. The original might exist specifically as the destination of an “On this page” link.
Before renaming or removing an existing hook, inspect its relevant references:
- CSS: selectors that style the element or depend on its position and children.
- Scripts: code that selects the element or attaches behavior.
- Fragment links: links within the site, and potentially from outside it, that target an ID.
- Accessibility relationships: attributes that reference IDs for labels or descriptions.
A name such as contact-details communicates more about purpose than right-box if the component may later move. That does not make every position-based name wrong; some genuinely describe layout responsibilities.
The useful principle is to make those responsibilities understandable and reasonably stable. Naming conventions can support that work, but a naming system cannot reveal dependencies that nobody has inspected.
Recognize When Repetition Needs Shared Ownership
Adding a second phone number to one page is a local task. Adding it to a contact block copied across twelve pages creates a consistency problem.
Separate copies can diverge. One may receive the new label, another may retain an old destination, and a third may acquire different markup during an unrelated edit. Shared ownership can make corrections easier to apply consistently when those instances genuinely represent the same pattern.
That might mean a shared template, a reusable editor block, or a structured contact-data source. The appropriate mechanism depends on the website.
Visual similarity alone is not enough reason to combine two blocks. A general contact list and a location-specific emergency contact panel may look alike while having different content rules and responsibilities.
Consider shared ownership when the same corrections repeatedly need to reach the same kinds of instances. Preserve separate patterns when their differences carry meaning. Reuse should reduce uncertainty, not conceal it behind conditional behavior that is harder to understand than the original markup.
Verify the Actual Edit
Return to the second phone number. Verification should follow what changed and what depends on it.
- Confirm the content. Check both numbers against the approved source. Make sure each visible description explains the number’s purpose.
- Check the destinations. Compare each displayed number with its
tel:value. Copying a link and changing only its visible text leaves a misleading destination. - Review the grouping. Ensure each description remains with its number and the heading still fits the page hierarchy.
- Inspect the layout. Check narrow and wide presentations for wrapping, clipping, and unexpected effects from adding another item.
- Check interaction. Confirm that the links are keyboard reachable, have visible focus, and activate as expected in the relevant environment. Telephone-link handling varies by device and configuration.
- Review affected references. If markup was copied or identifiers changed, check uniqueness and any links, labels, or descriptions that depend on those identifiers.
- Validate where appropriate. Use an HTML validator to help identify markup errors, including duplicate IDs. Review the rendered output when a template generates the page.
Validation cannot confirm that a number reaches the correct organization, that a label is useful, or that the entire interaction is accessible. It is one check within a broader HTML validation workflow, not a substitute for examining the result.
If the edit changes a shared template, check representative instances, including those with longer labels or different amounts of contact information. A local content addition does not automatically require a full-site audit; a shared structural change deserves a wider review.
The lasting benefit of small HTML decisions is not merely tidier source. It is a clearer account of what belongs together, what an element does, and what a future edit must preserve. The next maintainer should be able to understand the second phone number without first reverse-engineering the entire page.