The Exercise

The question comes from an hour-long technical discussion used in place of whiteboard interviews for a senior full-stack JavaScript role. Candidates share a screen, open Twitter.com's source, and walk through the top of the document line by line, saying as much or as little as they like. Partial answers count: hearing the right keywords is enough to steer the conversation deeper.

Document Setup

The doctype declaration

<!DOCTYPE html> is how much a candidate understands about rendering modes in miniature. The long-form declarations of the past (XHTML-era doctypes complete with specification links, similar to what SVGs carry today) existed because browsers had to choose among competing HTML standards, each producing a different layout. The short form was standardized in HTML5 and persists. A minimal acceptable answer: it tells the browser this is an HTML5 page and it should render it as such.

Root element attributes

<html dir="ltr" lang="en"> opens the root element and carries two attributes worth discussing. The dir attribute sets text direction — ltr, rtl for languages like Arabic, or auto to defer to the browser. The language attribute declares English for everything inside; it accepts any language tag, including regional variants such as en-us and en-gb, and screen readers use it to pick the right pronunciation. In practice, few interviewees knew dir, while most could reason out lang.

Character encoding and viewport

<meta charset="utf-8"> declares the encoding, and UTF-8 is the standard choice because its large character set covers symbols and emoji. Placement matters: the browser should encounter it before it has parsed much text — ideally at the very top of <head>. Twitter omits the <head> tag entirely to save bytes, though keeping it explicit gives metadata and styles an obvious home.

<meta name="viewport" content="width=device-...> is what makes a page size correctly on phones, a far cry from pinching and zooming through the full desktop New York Times on the original iPhone. width=device-width maps the viewport to the device width, eliminating horizontal scrolling, and initial-scale=1 is the convention. Twitter also sets user-scalable=0 and maximum-scale=1, which block zooming — bad for accessibility, but it makes the page feel more like a native app. Width plus initial scale is generally sufficient.

Sharing and App Metadata

<meta property="og:site_name" content="Twitt...> is an Open Graph tag naming the site. Facebook created the Open Graph protocol so links unfurl into rich previews with authorship details and cover images; auto-generating those images (with something like Puppeteer, for instance) is now common. One curiosity: meta tags normally use name, but OG uses the non-standard property. Its title, URL, and description tags duplicate ordinary meta tags, yet sites include them anyway for safety, mixing OG and other metadata to build previews.

<meta name="apple-mobile-web-app-title" cont...> targets homescreen pinning on iPhone. Since Safari doesn't support progressive web apps and no other browser engine is permitted on iOS, pinning is the only route to an app-like experience — so Twitter names the pinned app "Twitter." The following line governs the status bar appearance on launch.

Browser Chrome, Trials, and CSS Resets

<meta name="theme-color" content="#ffffff"...> is the standards-flavored counterpart to the Apple status bar tag: it themes the browser's surrounding UI, which Chrome on Android and Brave on desktop handle well. It accepts any CSS color, supports the media attribute for cases like dark themes, and can also be declared in a web app manifest.

<meta http-equiv="origin-trial" content="... is the line almost no one knew. Origin trials let a site ship experimental features while the user agent collects feedback and reports it to the standards community — no user opt-in flag required. One example on the standards track: Edge's origin trial for dual-screen and foldable device primitives, which enables layouts that react to whether a foldable is open or closed. "I don't know" was an acceptable answer here.

Then JavaScript begins: html{-ms-text-size-adjust:100%;-webkit-text.... The CSS text-size-adjust property controls whether a browser may enlarge text on small screens — none disables it, or a percentage caps the inflation. Twitter caps at 100% because the layout is already responsive and a browser-driven font bump could break it. Applied to the root element, it cascades everywhere. The property is experimental, hence the -ms- and -webkit- vendor prefixes; those prefixes date to the CSS3 era and disappear as properties stabilize. The preceding <style> tag is presumably on a minified earlier line.

The bonus line, body{margin:0;}, opens a natural follow-up on resetting versus normalizing. Browser user agent stylesheets differ, so resetting strips defaults (here, the body margin) to reduce inconsistencies; normalizing instead applies consistent defaults across browsers. The old * { margin: 0 } approach is overkill and costly, which is why normalize.css or reset.css imports became the norm.

Further Down the Page

Because Twitter is predominantly a client-side React app, its source is only a few dozen lines. Several more reward inspection:

  • An element telling browsers users can add Twitter as a search engine.
  • A tag with many discussable attributes, nonce especially.
  • Markup for international landing pages.
  • CSS removing the focus outline when navigation isn't keyboard-driven, with :focus-visible polyfilled.

The source code screenshots referenced throughout are not reproduced here.