Skip to content

HTML head and meta Tags: title, description, viewport, Open Graph, lang and dir="rtl"

NeedMyTools Academy

Sign in free to read the full lesson

Sign in or create a free account

Free forever. No card, no paywall.

Nothing in the <head> is shown on the page, yet it decides how the page looks on phones, what appears in Google results, what the preview card looks like when someone shares your link on WhatsApp, and whether an Arabic page reads in the right direction. For a site that serves both Arabic and English readers, these few lines matter as much as the content.

Quick answer

Every page needs <meta charset="utf-8">, <meta name="viewport" content="width=device-width, initial-scale=1">, a unique <title> and a <meta name="description">. Arabic pages use <html lang="ar" dir="rtl">; mixed or user-typed text gets dir="auto". Open Graph tags such as og:title and og:image control share previews.

20 min read and practice · Content checked on 20 October 2026

In this lesson you will

  • Write a complete head for any page
  • Write titles and descriptions that earn clicks honestly
  • Build Arabic and bilingual pages that display correctly

The essentials

<meta charset="utf-8"> should be the first thing in the head, within the first 1024 bytes of the file, so the browser reads every character correctly, including Arabic. The viewport tag tells phones to use the real screen width instead of pretending to be a 980 pixel desktop; without it, your page shows tiny and zoomed out on mobile.

<title> is the page name on the browser tab, in bookmarks and usually as the clickable headline in search results. Make every title unique and specific: "Gratuity Calculator UAE: End of Service Benefits" says far more than "Home". Search engines may cut long titles, so put the important words first.

<meta name="description" content="..."> is a one or two sentence summary. Google often shows it under the title, though it can choose other text from the page. It does not raise rankings by itself, but a clear, honest description gets more of the right people to click.

Try it: A complete head
Code
ResultUpdates as you type
Console
  1. Console messages, errors, form data and clicked links appear here.

The domain alnoor.example is a reserved example domain; replace it with your own.

Sign in free to read the full lesson

You are reading the free preview. Create a free account (it takes one minute, no password) to unlock the rest of this lesson and track your progress.

Unlocks after sign-in:

  • 2 more sections with live code examples
  • Common mistakes to avoid
  • Hands-on coding exercise with automatic checks
  • Practice quiz and the graded lesson test
Sign in or create a free account

Free forever. No card, no paywall.

Questions people ask

How long should a title tag be?

Google has no fixed limit and cuts titles by pixel width, so keep the key words in the first 50 to 60 characters. Longer titles are allowed; just make sure the start makes sense on its own.

Do meta keywords still matter?

No. Google has said publicly that it ignores the keywords meta tag. Spend the time on a better title, description and content.

Should the Arabic page have its own URL?

Yes. Google recommends a separate URL for each language version, such as /ar/ and /en/, rather than switching language with cookies on one URL, so each version can be found and linked with hreflang.

What is the difference between bdi and dir="ltr"?

<bdi> isolates text and guesses its direction, which suits names you do not know in advance. dir="ltr" on an element forces left to right, which suits code, phone numbers and URLs.

Do I need a favicon?

Browsers request /favicon.ico anyway, so add one to avoid errors in your logs and to make your tab recognisable. A single SVG icon plus a 180 pixel PNG for Apple devices covers most cases.

Sources

Facts in this lesson were checked against these official pages on 20 October 2026.

Code examples stay in English and run in a sandbox on your device. If you spot a mistake, tell us through the contact page.