HTML and CSS for beginners: build an international profile page
HTML gives a web page its structure and content; CSS controls how that content looks. You can learn both by building a profile card that handles different characters, reading directions and screen sizes.
The example runs locally in a browser, so you do not need a hosting account or framework to complete it. The content and translation tests are illustrative.
1. Set up the project
You need a plain-text editor, such as VS Code, and a browser.
- Create a folder called
profile-cardand open it in your editor. - Create two files inside it:
index.htmlandstyles.css. - Save both as UTF-8 without a byte order mark, or BOM.
- Optionally, install a live-preview extension to see changes in the browser as you work. An encoding-detection extension can help you inspect files received from someone else; check its result before converting a file.
UTF-8 represents text as bytes and supports characters from many writing systems. Declaring UTF-8 in HTML matters too, but the declaration cannot repair text that was saved incorrectly.
HTML and CSS have standards behind them. WHATWG develops the HTML Living Standard in collaboration with W3C, while W3C maintains CSS as separate specification modules. You do not need to read the specifications to begin, but they explain what browsers are expected to support.
2. Write the page in HTML
Put this in index.html and save it:
<!doctype html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Illustrative profile</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<main>
<article class="profile">
<header>
<p class="label">Illustrative profile</p>
<h1>Welcome to my profile</h1>
</header>
<p>I help teams share ideas across languages.</p>
<section aria-labelledby="about-heading">
<h2 id="about-heading">About this page</h2>
<p>This is a small project for learning HTML and CSS.</p>
<p>My working principle is <q>make room for every voice</q>.</p>
</section>
<a class="cta" href="#contact">Contact</a>
</article>
<footer id="contact">
<p>Add your preferred contact details here before publishing.</p>
</footer>
</main>
</body>
</html>
Open index.html in your browser. You should see headings, paragraphs and a link, even before adding CSS. The link takes you to the footer on the same page.
HTML uses elements to describe content. An element usually has an opening tag, content and a closing tag: <p>Text</p> is a paragraph. Attributes add information. For example, class="profile" gives CSS a way to select the article.
Elements also carry meaning. <main> identifies the main content, <article> contains the profile, and headings organize it. The <title> appears in places such as the browser tab; <h1> is the main heading on the page. The <link> element connects the stylesheet, while the viewport declaration helps the layout fit a narrow screen.
Change the heading, save the file and refresh. If nothing changes, check that you saved and opened the same file.
3. Declare language and direction
The opening tag describes the document:
<html lang="en" dir="ltr">
lang="en" identifies English. Its value is a BCP 47 language tag; es and es-ES are other examples. The page language is part of WCAG Success Criterion 3.1.1, which helps assistive technology identify the language for pronunciation. This declaration alone does not make a page accessible or translate it.
dir="ltr" sets left-to-right direction. For a page predominantly in a right-to-left language, set the corresponding language and dir="rtl" on <html>. Mark a passage in a different language separately:
<p lang="ar" dir="rtl">مرحبًا</p>
For text whose direction you do not know in advance, such as a user-supplied name, use dir="auto" on the element containing it. The browser determines its base direction from the content.
Keep the charset declaration at the start of <head> and save the files themselves as UTF-8. The W3C internationalization guidance explains encoding and language declarations in more detail.
4. Style the card with CSS
Put this in styles.css and save it:
* {
box-sizing: border-box;
}
body {
margin: 0;
background: #f2f5f7;
color: #17212b;
font-family: "Noto Sans", sans-serif;
line-height: 1.5;
}
main {
max-inline-size: 44rem;
margin-inline: auto;
padding: 1.5rem;
}
.profile {
background: white;
border-inline-start: 0.4rem solid #245a73;
padding: 1.5rem;
overflow-wrap: anywhere;
}
.profile + .profile {
margin-block-start: 1.5rem;
}
.label {
color: #245a73;
font-weight: bold;
}
h1 {
font-size: clamp(1.8rem, 5vw, 2.5rem);
}
.cta {
display: inline-block;
box-sizing: border-box;
min-inline-size: min(100%, clamp(12rem, 40vw, 21rem));
max-inline-size: 100%;
padding: 0.75rem 1rem;
background: #174d68;
color: white;
text-align: center;
}
:lang(ar) {
font-family: "Noto Sans Arabic", sans-serif;
}
q:lang(en) {
quotes: """ """ "'" "'";
}
q:lang(ar) {
quotes: "«" "»" "‹" "›";
}
footer {
margin-block-start: 1.5rem;
}
Refresh the browser. The card should have a white background, a colored border and a styled contact link. If it does not, check the stylesheet's name, location and <link> in the HTML.
A CSS rule has a selector and declarations. In body { color: #17212b; }, body selects the page body and color sets its text color. A dot selector such as .profile selects elements with that class.
The box model explains spacing: content sits inside padding, a border surrounds the padding, and margin creates space outside the border. clamp() lets the heading size adjust with the viewport between a lower and upper limit. max-inline-size limits the content width without forcing it to stay wide on a small screen.
The :lang() selector styles content according to its declared language. Here it selects an Arabic font preference and gives <q> elements different illustrative quote marks. Choose quote conventions appropriate to the actual language and editorial style.
Noto Sans is a broad-coverage font family; the example also names Noto Sans Arabic. Naming a font does not download it. If it is not installed or loaded, the browser uses a fallback. Check the actual scripts and marks you need.
5. Test the same card in another direction
Add this second article inside <main>, after the first card and before the footer:
<article class="profile" lang="ar" dir="rtl">
<h2>مرحبًا</h2>
<p>هذه صفحة للتعلم.</p>
<p><q>أهلًا وسهلًا</q></p>
<a class="cta" href="#contact">تواصل معنا</a>
</article>
Save and refresh. The Arabic card uses the same class, but its text direction and starting border should appear on the right. Change dir temporarily to ltr to see the border move, then restore it.
The stylesheet uses logical properties, which follow the direction of content:
- Use
margin-inline-start,padding-inlineorborder-inline-startwhen a side should follow the start or end of a line. - Use
margin-block-startfor spacing before an element in the block flow, rather than assuming that side is always the top. - Use a physical property such as
leftormargin-leftwhen the design refers to the screen's left side regardless of language.
Logical properties do not promise that every browser supports every feature. Check the particular property against your audience's browsers in the Can I use compatibility tables. If you need an older browser, test an appropriate fallback in both directions; a fixed margin-left fallback alone will not mirror in RTL.
6. Size the contact link for translations
Short labels can expand by two to three times in translation. A fixed-width button that fits one label may clip another. Start with a sizing exercise, then test actual text rather than treating character counts as exact widths.
The illustrative English label Contact has seven letters. A three-times planning allowance is 21 letters. Try it alongside Kontakt aufnehmen and تواصل معنا. These are examples to test, not a guarantee of the final wording.
The .cta rule gives the link a preferred minimum that grows from 12rem toward 21rem as the viewport widens. min(100%, ...) prevents that minimum from exceeding its container; max-inline-size and wrapping keep a longer label inside it. The link has padding but no fixed height, so it can grow to multiple lines.
This is a starting size, not a conversion from letters to pixels. Arabic, Latin letters and spaces have different widths, and the chosen font changes the result. At a narrow viewport, verify that each label wraps without clipping and that the link remains usable. With several controls in a row, use flex-wrap: wrap so they can move onto another line.
Keep line spacing generous enough for the scripts you use; the example starts at 1.5. Keep words as HTML text rather than embedding them in images, so they can be selected, resized and translated. HTML and CSS display the values you provide; dynamic locale formatting for dates, numbers and currencies requires code such as JavaScript's Intl API.
7. Inspect your work
Narrow the browser window and check both cards, including longer labels. Text should remain readable without being cut off. If something looks wrong, open browser DevTools and inspect the affected element:
- In the layout or styles panel, check its size, inherited direction and applied CSS rules.
- In the network panel, refresh and look for a stylesheet or font that failed to load.
- In the console, look for reported errors. If characters are corrupted, check both the saved encoding and the HTML declaration; correct any text that was already damaged.
The Pro section adds a reusable starter, a worked test matrix and a hosting walkthrough with deployment checks and a learning roadmap.
Reuse a small international starter
Save this as index.html for a new project. It is self-contained; move the styles into a separate file when the project grows. Replace the illustrative content and update lang and dir to match the actual page.
<!doctype html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>New profile</title>
<style>
* { box-sizing: border-box; }
body {
margin: 0;
color: #17212b;
background: #f2f5f7;
font-family: "Noto Sans", sans-serif;
line-height: 1.5;
}
main {
max-inline-size: 44rem;
margin-inline: auto;
padding: 1.5rem;
}
article {
background: white;
border-inline-start: 0.4rem solid #245a73;
padding: 1.5rem;
overflow-wrap: anywhere;
}
h1 { font-size: clamp(1.8rem, 5vw, 2.5rem); }
:lang(ar) { font-family: "Noto Sans Arabic", sans-serif; }
q:lang(en) { quotes: """ """ "'" "'"; }
q:lang(ar) { quotes: "«" "»" "‹" "›"; }
</style>
</head>
<body>
<main>
<article>
<h1>Illustrative profile</h1>
<p>Replace this with your introduction.</p>
<p><q>Replace this quotation too.</q></p>
<a href="mailto:[email protected]">Contact</a>
</article>
</main>
</body>
</html>
The email address is a placeholder, not a working contact. Replace or remove the link before publishing. As in the tutorial, the named fonts use local fonts or browser fallbacks unless you separately load font files.
Run a compact pre-deployment test
Copy this matrix into your project notes and replace the illustrative results with observations from your own browsers and devices.
| Scenario | Expected | Illustrative observation and action |
|---|---|---|
| English, narrow viewport | Card and CTA fit without clipping | Long CTA wraps; check that the link remains easy to use |
| Arabic card, narrow viewport | Text and start border follow RTL | Border appears on the right; have the actual translation reviewed |
| Published page | Same content and styles as local version | Styles missing: check filename case and the network panel |
Before uploading, inspect these items:
- Content: Remove placeholders, private information and unintended contact details. Check each link's destination.
- Language and direction: Match
langanddirto the actual content. Test mixed-direction names and links as well as whole RTL passages. - Encoding and layout: Save files as UTF-8, verify the charset declaration, and test long labels and narrow screens. Recheck logical-property fallbacks in target browsers.
- Fonts: If you load web fonts, check the network panel for successful requests and inspect the characters used by each language. A font subset contains only selected characters or scripts. It can reduce downloaded font data, but a subset missing a required character can cause fallback or missing glyphs. Include every script and mark your content needs, and test the published result.
- Delivery: After publishing, check HTTPS, the stylesheet and font requests, and response cache headers. A local test cannot show whether the host serves the intended files.
Publish the profile with Netlify
A static host serves files without requiring this profile to have a backend. A CDN, or content delivery network, caches files at distributed edge locations so visitors can receive them from a closer server. Coverage and caching depend on the service and configuration.
For a first manual deployment:
- Make sure
index.htmlandstyles.cssare together at the top level ofprofile-card. Save your changes. - Create or sign in to a Netlify account. Open Netlify's manual deployment interface, often called Netlify Drop.
- Drag the
profile-cardfolder into the upload area. Follow the on-screen prompts to publish it. - Open the generated site address over HTTPS. Check both cards, the contact link and the browser's network panel. If the page is unstyled, confirm that
styles.csswas uploaded with the exact filename used in the HTML. - To publish a later edit, upload the updated folder again through the deployment interface. Reopen the public address and verify the changed content.
A manual upload is useful for a first page. For frequent changes, consider connecting a Git repository and configuring the host's automatic deployment workflow. Keep secrets and private files out of the folder you publish.
Compare hosts before choosing a plan
Netlify, Vercel and GitHub Pages are options for static sites, but do not assume that a particular plan, region or traffic level will stay free.
- Hosting workflow: Compare manual uploads with repository-based publishing. Check the build and output settings required for a plain folder of HTML and CSS.
- HTTPS and domain: Check how the host provisions HTTPS for its generated address and for any custom domain you want to use.
- CDN and caching: Check current edge coverage for your audience, which files are cached, cache-header controls and how updates become visible. A distributed CDN does not guarantee the same performance everywhere.
- Pricing: Read the current plan and usage terms, including bandwidth, build activity, overages and any custom-domain charges. Prices and allowances change; verify them on the provider's official pricing pages for Netlify, Vercel and GitHub before committing.
Use DevTools on the published page to inspect response headers and confirm what your chosen configuration actually sends. If an old version persists, check the host's deployment and cache behavior before changing the page again.
Fix common mistakes and choose what to learn next
When a page breaks, make the smallest change that addresses the cause, then repeat the tests in both directions.
- Missing or wrong charset: A UTF-8 declaration cannot undo corrupted source text. Correct the text and save the file in UTF-8.
- Everything built from generic containers: Use headings, sections and links for their meaning. A semantic link also gives navigation behavior that a styled generic container does not.
- Styles scattered through HTML: Repeated inline styles make direction and spacing fixes harder to maintain. Put shared component rules in a stylesheet.
- Fixed dimensions around text: A fixed height can hide a longer translation. Let the box grow and test real labels at narrow widths.
- Text baked into images: Each translation may require a new image. Keep the words in HTML and use an image as decoration where appropriate.
- Physical sides used by habit: A left border may be correct for one layout but wrong for another. Decide whether the side should follow content direction before choosing the property.
Next, learn Git for version control so you can track changes and recover earlier versions. Use the JavaScript beginner's guide to add behavior and explore Intl for locale-aware values. Once you can build and debug small pages with those foundations, the React starter guide introduces reusable interface components.


