Namaste, future full-stack developers! Welcome to your very first step into the world of web development. Today, we’re diving into HTML – the backbone of every website you interact with. HTML, or HyperText Markup Language, isn’t a programming language; it’s a markup language that tells your web browser how to display content. Think of it as the blueprint for your house, defining where the walls, doors, and windows go.
In this lesson, we’ll cover the fundamental ‘objectives’ of creating a basic web page: how to set up your HTML document, structure content with headings and lists, embed images, and link to other pages. By the end, you’ll be able to craft simple, yet functional, web pages!
Before we write any code, let’s understand the process of bringing an HTML file to life in your browser.
.html or .htm extension (e.g., index.html, my-first-page.html). This tells your operating system and browser that it’s an HTML document.Every HTML document follows a basic structure. This boilerplate code provides the necessary framework for your web page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First HTML Page</title>
</head>
<body>
<!-- Your visible content goes here -->
<h1>Hello, FullStackDost!</h1>
</body>
</html>
<!DOCTYPE html>: This declaration defines the document type and version of HTML (HTML5 in this case). It must be the very first thing in your HTML document.<html lang="en">: This is the root element of an HTML page. The lang="en" attribute specifies the primary language of the document, which is good for accessibility and search engines.<head>: This section contains meta-information about the HTML document, such as its title, character set, links to stylesheets, and other metadata not visible on the page itself.<meta charset="UTF-8">: Specifies the character encoding for the document, ensuring proper display of various characters.<meta name="viewport" content="width=device-width, initial-scale=1.0">: Crucial for responsive web design, ensuring your page looks good on different devices.<title>My First HTML Page</title>: Sets the title that appears in the browser tab or window title bar.<body>: This section contains all the visible content of your web page, including text, images, links, videos, and more.Headings are vital for structuring your content, making it readable for both users and search engines. HTML provides six levels of headings, from <h1> (most important) to <h6> (least important).
<body>
<h1>Welcome to My Profile Page</h1>
<h2>About Me</h2>
<p>I am a passionate learner on the journey to become a full-stack developer.</p>
<h3>My Hobbies</h3>
<h4>Coding</h4>
<h5>Reading</h5>
<h6>Gaming</h6>
</body>
Pro Tip: Use headings semantically. <h1> should typically be used once per page for the main title, and subsequent headings should follow a logical hierarchy, just like an outline in a book.
Lists are perfect for presenting information in an organized, easy-to-read format. HTML offers two main types:
<ul>)Unordered lists display items with bullet points. They are created using the <ul> tag, and each list item is enclosed within an <li> tag.
<h2>My Favorite Hobbies</h2>
<ul>
<li>Learning Full-Stack Development</li>
<li>Playing Cricket</li>
<li>Exploring New Technologies</li>
</ul>
<ol>)Ordered lists display items with numbers or letters, indicating a sequence or ranking. They are created with the <ol> tag, and each item uses the <li> tag.
<h2>My Top 3 Programming Languages to Learn</h2>
<ol>
<li>JavaScript</li>
<li>Python</li>
<li>Java</li>
</ol>
A picture is worth a thousand words! Images make your web pages more engaging. The <img> tag is used to embed an image. It’s a self-closing tag, meaning it doesn’t have a separate closing tag.
<h2>My Profile Picture</h2>
<img src="profile.jpg" alt="A friendly person learning full-stack development" width="200" height="200">
src (source): This attribute specifies the path to the image file. It can be a relative path (e.g., profile.jpg if in the same folder) or an absolute URL (e.g., https://example.com/images/profile.jpg).alt (alternative text): This is crucial! It provides a textual description of the image for screen readers (for visually impaired users), when the image fails to load, or for search engines. Always include a descriptive alt attribute.width and height: These attributes specify the dimensions of the image in pixels. While you can use them, it’s generally better practice to control image sizing with CSS for more flexibility.Links are what make the web, well, the web! They allow users to navigate between pages, documents, or even different sections of the same page. The <a> tag (anchor tag) is used to create a hyperlink.
<h2>Connect with Me</h2>
<p>Visit my <a href="https://www.linkedin.com/in/fullstackdost/" target="_blank">LinkedIn Profile</a> for more updates.</p>
<h3>Image Link Example</h3<
<a href="https://fullstackdost.com" target="_blank">
<img src="logo.png" alt="FullStackDost Logo" width="150">
</a>
href (hypertext reference): This attribute specifies the destination URL or path that the link points to.target="_blank": This attribute tells the browser to open the linked document in a new tab or window. If omitted, the link will open in the current tab.<a> tags.<img> tag inside an <a> tag to make the image clickable.It’s time to put your new HTML skills into action! Create a new HTML file called my_profile.html and build a simple personal profile page that includes the following:
<!DOCTYPE html>, <html>, <head>, and <body> tags.<title> to “My FullStackDost Profile”.<h1> with your name (e.g., “John Doe’s Profile”).<h2> for “About Me” and a paragraph (<p>) describing yourself briefly.<ol>) of 3-5 technical skills you’re learning or interested in (e.g., HTML, CSS, JavaScript).<ul>) of 3-5 personal hobbies or interests.<img> tag. Make sure to include a descriptive alt attribute and set width/height.<a>) to your LinkedIn profile, GitHub, or any other social media. Make sure it opens in a new tab!Save your file and open it in your browser. Congratulations, you’ve just built your first structured web page!
Fantastic work today! You’ve learned the essential building blocks of any web page:
<head> and <body>.<h1> to <h6> for semantic headings.<ul> (unordered) and <ol> (ordered) lists.<img> tag with src and the crucial alt attribute.<a> tag and the href attribute.These elements are the foundation upon which all web content is built. Keep practicing, and soon you’ll be building much more complex and interactive web experiences. Keep learning, keep growing, and I’ll see you in the next lesson!