A Beginner’s Guide to HTML5 and CSS3 — Understanding the Basics

Alexander Obregon
2 min readApr 30, 2023
Image Source

Introduction

HTML5 and CSS3 are essential building blocks of modern web development. HTML5 provides the structure and content of a webpage, while CSS3 defines its style and appearance. In this beginner’s guide, we will explore the basics of HTML5 and CSS3, as well as provide code examples to help you get started with creating your own webpages.

HTML5 Basics

Elements and tags

HTML5 elements are the building blocks of a webpage. Each element is represented by a tag. An opening tag marks the start of an element, and a closing tag marks its end. Most elements have both opening and closing tags, while some elements are self-closing.

Example:

<!DOCTYPE html>
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1>Welcome to My Webpage!</h1>
<p>This is a paragraph of text.</p>
<img src="image.jpg" alt="An example image" />
</body>
</html>

The structure of an HTML5 document

An HTML5 document has a specific structure, starting with the DOCTYPE declaration, which indicates the version of HTML being used. Following the DOCTYPE is the opening and closing <html> tag. Within the <html> element are two main elements: <head> and <body>.

  • <head>: Contains meta-information and the page title.
  • <body>: Contains the main content of the page, such as text, images, and links.

CSS3 Basics

Selectors and properties

CSS3 uses selectors to target HTML elements and apply styling to them. Properties are the specific styles that you want to apply, such as color, font size, or margin.

Example:

h1 {
color: blue;
font-size: 24px;
text-align: center;
}

p {
font-family: Arial, sans-serif;
font-size: 14px;
line-height: 1.5;
}

Inline, internal, and external styles:

CSS3 styles can be added to HTML documents in three ways:

  • Inline: Directly in the element’s opening tag, using the style attribute.
  • Internal: Inside a <style> tag in the <head> section of the document.
  • External: In a separate .css file, which is linked to the HTML document using a <link> tag in the <head> section.

Example:

Inline style:

<p style="color: red; font-size: 16px;">This is a paragraph with inline style.</p>

Internal style:

<head>
...
<style>
p {
color: green;
font-size: 16px;
}
</style>
</head>

External style:

HTML document

<head>
...
<link rel="stylesheet" href="styles.css">
</head>

styles.css

p {
color: purple;
font-size: 16px;
}

Conclusion

Now that you have a basic understanding of HTML5 and CSS3, you can start building your own webpages. Practice creating various elements, and experiment with different styles to develop your skills. As you become more comfortable with HTML5 and CSS3, explore additional resources and tutorials to expand your knowledge and take your web development skills to the next level.

  1. W3Schools — HTML5 Tutorial
  2. Mozilla Developer Network — CSS Tutorial

--

--

Alexander Obregon

Software Engineer, fervent coder & writer. Devoted to learning & assisting others. Connect on LinkedIn: https://www.linkedin.com/in/alexander-obregon-97849b229/