Web Design
Beautiful, responsive designs
Part 4: Building Proper HTML Documents
Senior Full-Stack Developer
Document Type Declaration - Tells browser this is HTML5
Must be the first line - defines HTML version
Root element wrapping entire document
Contains metadata - not visible to users
Contains visible content users interact with
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Awesome Website</title>
</head>
<body>
<header>
<h1>Welcome to My Site</h1>
</header>
<main>
<section>
<h2>About Me</h2>
<p>This is my personal website.</p>
</section>
</main>
<footer>
<p>© 2024 My Website</p>
</footer>
</body>
</html>
This is my personal website.
<!DOCTYPE html> is the shortest possible doctype for HTML5
The <html> element is the root container
lang attribute for accessibility<html lang="en"> for EnglishDefines the document title
Shown in browser tabs, bookmarks, and search results. Crucial for SEO.
Character encoding
Defines the character set for the document. UTF-8 supports all characters and symbols.
Responsive design
Controls viewport size and scaling for responsive web design on mobile devices.
Page description
Provides a summary of page content for search engines and social media.
External resources
Links to external resources like CSS files, favicons, and web fonts.
JavaScript code
Embeds or links to JavaScript code. Can be placed in head or body.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Learn web development with DevVoltz Academy">
<meta name="keywords" content="HTML, CSS, JavaScript, web development">
<meta name="author" content="Simegnew Destew">
<title>DevVoltz Academy - Master Web Development</title>
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.ico">
<script src="script.js" defer></script>
</head>
This page demonstrates how the <title> tag affects the browser tab.
Look at your browser tab to see the current title!
Identifies pages when multiple tabs are open
Used as default name when users bookmark pages
Appears as the clickable headline in search engines
Screen readers announce the title when page loads
<body>
<header>
<nav>
<!-- Navigation links -->
</nav>
</header>
<main>
<article>
<section>
<!-- Main content sections -->
</section>
</article>
<aside>
<!-- Sidebar content -->
</aside>
</main>
<footer>
<!-- Footer content -->
</footer>
</body>
Search engines understand content structure better
Screen readers can navigate content more effectively
Clear structure makes code easier to read and update
Semantic elements adapt better to new devices and technologies
Introductory content or navigation
Navigation links
Primary content of the document
Self-contained composition
Thematic grouping of content
Content indirectly related to main content
Footer for its nearest sectioning content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Professional web development services">
<title>WebDev Pro - Professional Web Development</title>
<link rel="stylesheet" href="styles.css">
<link rel="icon" type="image/x-icon" href="/favicon.ico">
</head>
<body>
<header>
<nav>
<div class="logo">WebDev Pro</div>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section id="hero">
<h1>Transform Your Digital Presence</h1>
<p>Professional web development solutions</p>
<button>Get Started</button>
</section>
<section id="services">
<h2>Our Services</h2>
<div class="service-grid">
<article>
<h3>Web Design</h3>
<p>Beautiful, responsive designs</p>
</article>
<article>
<h3>Web Development</h3>
<p>Robust, scalable solutions</p>
</article>
</div>
</section>
</main>
<footer>
<p>© 2024 WebDev Pro. All rights reserved.</p>
</footer>
<script src="script.js"></script>
</body>
</html>
Professional web development solutions
Beautiful, responsive designs
Robust, scalable solutions
You've Learned HTML Page Structure
Basic HTML document structure
HTML version specification
Root container with lang attribute
Metadata, title, and resource links
Browser tab and SEO importance
Semantic structure and content
Create a well-structured HTML document for a portfolio website with:
Choose elements that describe their content
Essential for responsive design
Always include lang attribute for accessibility
Make titles unique and meaningful
Next: Learn about headings, paragraphs, lists, and text formatting tags