
HTML is the backbone of the web, and mastering it is essential for web development. HTML is not a programming language, but rather a markup language used to create structure and content on the web.
A basic HTML document consists of a series of elements, such as headings, paragraphs, and links, which are represented by tags. These tags are surrounded by angle brackets and contain the content that will be displayed on the web page.
HTML elements can be categorized into different types, including block-level elements and inline elements. Block-level elements, like headings and paragraphs, start on a new line and take up the full width of the web page.
Consider reading: What Are Headings in Html
HTML Elements
HTML Elements are the building blocks of a web page, and they're used to create structure and content.
A heading element is used to define headings and subheadings, such as h1, h2, h3, and so on.
The paragraph element is used to define a block of text, which is the main content of a web page.
You can also use elements like div, span, and p to add structure and meaning to your content.
Broaden your view: The Html Canvas Element Is Used to
The P
The P tag is a versatile element in HTML. It defines a paragraph of text.
You can add any inline element you like inside a P tag, such as a span or an anchor tag. This makes it easy to add emphasis or links to your text.
A P tag is a block element, which means it takes up a whole line on the page.
You can't add block elements inside a P tag, so be mindful of what you nest inside it.
Recommended read: Html Li inside Li
The Br
The br tag is a simple yet useful element in HTML. It represents a line break and is an inline element that doesn't need a closing tag.
Using the br tag is a great way to create a new line inside a paragraph without starting a new paragraph, which can be helpful when you want to break up text but don't want extra spacing.
For another approach, see: Html No Break
The Strong
The strong tag is a powerful tool in HTML. It's used to mark text as strong, which means it's not just a visual hint but a semantic one.
Explore further: Black Html Color Code
This tag is important because its interpretation will vary depending on the medium used. Browsers by default make the text in this tag bold.
The strong tag is not just for visual appeal, but it also conveys meaning. It's a way to indicate that the text inside it is of great importance or emphasis.
Browsers automatically make the text in the strong tag bold, so you don't need to add any extra styles to achieve this effect.
Take a look at this: Why Is My Bold Text in Html Not Working
Attributes and Text
Attributes have the key="value" syntax, and some attributes are boolean, meaning you only need the key.
The class and id attributes are two of the most common you will find used, and they have a special meaning in both CSS and JavaScript.
An id is unique in the context of a web page and cannot be duplicated, while classes can appear multiple times on multiple elements.
Classes can hold multiple values, separated by a space, and it's common to use the dash - to separate words in a class value.
Curious to learn more? Check out: Html Entity Meaning Partial
Attributes
Attributes are a crucial part of HTML, and they can be attached to the starting tag of an element.
You can use attributes with the key="value" syntax, and some attributes are boolean, meaning you only need the key.
The class and id attributes are two of the most common you will find used, and they have a special meaning, being useful both in CSS and JavaScript.
An id is unique in the context of a web page and cannot be duplicated, whereas classes can appear multiple times on multiple elements.
You can separate multiple values in a class value with a space, and it's common to use the dash - to separate words in a class value.
Some attributes are only used for one tag and are highly specialized, while others can be used in a more general way.
The style attribute can be used to insert inline CSS rules on an element, making it a useful attribute in certain situations.
Expand your knowledge: Nbsp Meaning in Html
Other Text
There are several other text tags that are less commonly used. The mark tag is one of them.
The ins tag is used to indicate that the text is inserted, while the del tag is used to indicate that the text is deleted. I've seen these tags used in digital documents to highlight changes.
The sup and sub tags are used to indicate superscript and subscript text respectively. They're useful when you need to display mathematical formulas or chemical equations.
Here are some other text tags you might come across:
- the mark tag
- the ins tag
- the del tag
- the sup tag
- the sub tag
You might wonder how these tags are different from the b and i tags. The difference lies in their semantic meaning, and how they're styled by the browser.
Images and Media
All images must have an alt tag describing the image content, it's not just a good practice, it's required by the HTML standard.
The figure tag, often used when you want to display an image with a caption, is a semantic tag that helps with accessibility and SEO.
The figcaption tag wraps the caption text, making it easy to add a description to your images.
The picture tag does a very similar job to srcset, but the differences are very subtle, so use it when you need to.
A different take: Html Image Caption
Add Alt Text to Images
Adding alt text to images is a must, and it's not just a good practice, it's actually required by the HTML standard.
You see, all images must have an alt tag describing the image content, and without it, your HTML won't be validated.
The figure tag is often used to display an image with a caption, and it pairs perfectly with the figcaption tag, which wraps the caption text.
But let's get back to alt text - it's essential for accessibility and search engine optimization, and it's also a great way to add context to your images.
The HTML standard is clear: all images must have an alt tag, and it's not just a suggestion, it's a requirement.
Intriguing read: Can You Do Freelancing with Just Html and Css
The Picture
The picture tag is a great tool for serving different image formats to different browsers. It's perfect for serving WebP images, which are still not widely supported.
You can specify a list of images in the picture tag, and browsers will use them in order. For example, if you specify a WebP image first, browsers that support it will use it, and those that don't will fallback to JPG.
For your interest: Html for Different Fonts

The source tag defines one or more formats for the images, and you can add a media attribute to set media queries. This is useful for targeting specific devices or screen sizes.
The picture tag is relatively new, but it's now supported by all major browsers except Opera Mini and IE (all versions).
For your interest: Social Network Buttons Html
The Audio
The audio tag is a powerful tool for embedding audio content in your HTML pages. It can stream audio using a microphone or play an audio source referenced by the src attribute.
By default, the browser doesn't show any controls for this element, so the audio will only play if set to autoplay. To show the built-in controls, you can add the controls attribute.
The controls attribute can have a custom skin, allowing you to tailor the look and feel of your audio player. You can also specify the MIME type of the audio file using the type attribute, although the browser will try to automatically determine it if not set.
For another approach, see: Using Oembed in Base Html
An audio file by default does not play automatically. Add the autoplay attribute to play the audio automatically, but note that mobile browsers don't allow autoplay.
To control the playback of the audio, you can use the loop attribute, which restarts the audio playing at 0:00 if set. Otherwise, the audio will stop at the end of the file.
Here are the basic events you can listen for using JavaScript on an audio element:
- play when the file starts playing
- pause when the audio playing was paused
- playing when the audio is resumed from a pause
- ended when the end of the audio file was reached
The Video
The video tag is a powerful tool for embedding video content in your HTML pages. It allows you to stream video from a webcam or play a video source referenced using the src attribute.
You can specify the MIME type of the video file using the type attribute, or let the browser automatically determine it. The video file does not play automatically, but you can add the autoplay attribute to play it automatically.
Some browsers require the muted attribute to autoplay, so be sure to include that as well. The video will only play if both autoplay and muted attributes are present. If not present, the browser will display the first frame of the video as soon as it's available.
Additional reading: Autoplay Video in Html
You can also use the loop attribute to restart the video playing at 0:00 if set, or let it stop at the end of the file if not present.
Here are the basic events you can listen for on a video element using JavaScript:
- play: when the file starts playing
- pause: when the video was paused
- playing: when the video is resumed from a pause
- ended: when the end of the video file was reached
Forms and Validation
Forms are the way to interact with a page or app built with Web technologies. You can create a form using the form tag, which is the foundation for collecting data from users.
By default, forms are submitted using the GET HTTP method, but it's recommended to use POST instead due to its drawbacks. You can set the form to use POST by adding the method attribute.
You can specify the URL where the form data will be sent using the action parameter. This means you need to have something server-side to handle the request, and typically, you listen for form submit events on a dedicated URL.
Curious to learn more? Check out: How to Get Url of Image for Html
Here are the types of controls available on the Web platform to provide data to forms:
- input boxes (single line text)
- text areas (multiline text)
- select boxes (choose one option from a drop-down menu)
- radio buttons (choose one option from a list always visible)
- checkboxes (choose zero, one or more option)
- file uploads
Browsers provide client-side validation functionality to forms, allowing you to set fields as required and enforce a specific format for the input of each field. The required attribute helps you with validation, and if the field is not set, client-side validation fails and the browser does not submit the form.
Take a look at this: Php Html Form Validation
Forms
Forms are the way you interact with a page or app built with Web technologies. They're created using the form tag, and by default, they're submitted using the GET HTTP method.
You can set the form to use POST instead by adding the method attribute. This is usually what you want, as GET has its drawbacks. Typically, you'll want to use POST to send data to the server.
A form is submitted to the same URL where it resides. If the form is in a page like https://flaviocopes.com/contacts, pressing the "submit" button will make a request to that same URL. You need something server-side to handle the request.
Here's an interesting read: Post Request Html Form
You can specify the URL to submit the form data to using the action parameter. This will cause the browser to submit the form data using POST to the specified URL. For example, if you set the action parameter to "/new-contact", the form data will be sent to https://flaviocopes.com/new-contact.
Forms can contain a variety of controls, including input boxes, text areas, select boxes, radio buttons, checkboxes, and file uploads. These controls allow users to provide data to the form.
Here are some examples of form controls:
- input boxes (single line text)
- text areas (multiline text)
- select boxes (choose one option from a drop-down menu)
- radio buttons (choose one option from a list always visible)
- checkboxes (choose zero, one or more option)
- file uploads
There's also a special field rendered as a button that can clear the entire form and bring back the state of the fields to the initial one.
For more insights, see: Html Tag B
Range
The Range input element is a versatile tool for gathering numerical input from users. It allows people to move a slider from a starting value to an ending value.
You can customize the Range element by specifying a step attribute, which determines the increments between values. This is optional, but it's a great way to make the input more user-friendly.
Consider reading: Range Input Html
For example, if you want users to input values in increments of 5, you can specify the step attribute as "5". This helps users understand what values are being accepted.
The Range element also allows for additional validation through the pattern attribute. This can be used to restrict input to a specific format, such as a range of numbers between 0 and 100.
You might enjoy: Html 5 or Javascript
The Select
The Select is a powerful form element that allows users to choose from a list of options. It's commonly used to create drop-down menus.
You can create a select tag to give users a list of options to choose from, and each option is created using the option tag. The option tag requires a name to be added to the select, and a value to each option.
Setting an option as disabled is easy, just add the disabled attribute to the option tag. This prevents users from selecting that option.
You can also have one empty option in a select tag, it's a good way to provide a placeholder for users.
Take a look at this: Html Option Selected
Accessibility
Accessibility is crucial for making your website usable by everyone. The tabindex attribute allows you to change the order of how pressing the Tab key selects elements.
By default, only links and form elements are selectable by navigation using the Tab key, but adding tabindex="0" makes any element selectable. This is particularly useful for elements like buttons or images that you want users to interact with.
ARIA attributes, which stands for Accessible Rich Internet Applications, define semantics that can be applied to elements, making them more accessible.
Additional reading: Key in Html
Use Aria Attributes
Using Aria Attributes can make a big difference in making your website more accessible. ARIA stands for Accessible Rich Internet Applications and defines semantics that can be applied to elements.
ARIA attributes are used to add meaning to elements, making it easier for screen readers and other assistive technologies to understand their purpose. This is especially useful for elements that don't have an explicit label, like the search input box on my blog.
The aria-label attribute is a great way to add a string to describe an element. I use this attribute on my blog sidebar, where I have a search input box without an explicit label, as it has a placeholder attribute.
Additional reading: Add Css and Html to Blog Post Wordpress
Use Semantic
Using semantic HTML is crucial for accessibility. It's one of the main things you need to take care of.
The structure of heading tags is important. Use h1 for the most important headings, and higher numbers for less important ones, but all same-level headings should have the same meaning, like a tree structure.
Use strong and em instead of b and i. Visually they look the same, but strong and em have more meaning associated with them.
A table should have a caption tag that describes its content. This helps screen readers understand the table's purpose.
Here's an interesting read: Emphasis in Html
CSS and Styling
CSS is a language used to add styles to web pages, and it can be added directly to the document using the style tag.
You can use the media attribute with the style tag to specify that the CSS should only be applied to a certain medium, such as a screen or print.
The style tag is a useful alternative to loading an external stylesheet, and it can be a great way to add a touch of personal style to your web pages.
You might like: Is Html Used to Create Web Pages
White Space
White space is pretty important in HTML, as it's collapsed by the browser's CSS engine, regardless of how many white spaces you add to a line.
In other words, the rendering of a paragraph with multiple white spaces is the same as one with just a single space.
You can change how things behave using the white-space CSS property, which you can find more information on in the CSS Spec.
Nested tags should be indented with 2 or 4 characters, depending on your preference.
The HTML entity can be used in special cases, but it's not recommended to abuse it, as CSS is always preferred to alter the visual presentation.
Here are some examples of unordered lists:
- unordered lists
- ordered lists
- definition lists
CSS for Marketers
CSS is a language that helps you control the layout and visual styling of your website, allowing you to make it look exactly how you want.
Knowing the basics of CSS is essential for creating a professional-looking website, as it tells web browsers how to display the content defined by HTML.
CSS stands for Cascading Style Sheets, and it's a sibling language to HTML, working together to create a visually appealing website.
By learning CSS, you can create a website that stands out and makes a great impression on your audience.
My personal experience has shown that learning CSS opened up opportunities for me to create, design, and help manage websites, making me stand out in my career.
With CSS, you can control the layout, color, and font of your website, making it easy to create a consistent look and feel.
Knowing how to code some basic CSS is a great starting point, and I'll be happy to guide you through it in this article.
Chapters and Content
In an HTML booklet, you'll find a clear structure that helps you navigate through the content. The chapters are listed out in an easy-to-follow format.
Here are the main chapters you can expect to find:
- What is HTML?
- How to Write HTML
- How to Create an HTML File
- Common HTML Elements
- Common HTML Attributes
- How to Learn HTML
The content of an HTML element is what the user actually sees on the webpage, and it's placed between the opening and closing tags. This can include text, links, images, lists, or tables.
Chapters

Let's talk about chapters and how they're structured. A chapter is typically a self-contained section of content, like the ones in a book or online tutorial.
The chapters in our HTML tutorial are designed to take you from the basics to more advanced topics. For example, Chapter 1, "What is HTML?", gives you a solid introduction to the subject.
Chapter 2, "How to Write HTML", dives deeper into the code and shows you how to create your own HTML documents. This is where things can get a bit more technical, but don't worry, it's still easy to follow.
Here's a list of our chapters, so you can see the progression:
- What is HTML?
- How to Write HTML
- How to Create an HTML File
- Common HTML Elements
- Common HTML Attributes
- How to Learn HTML
By the time you reach Chapter 5, "Common HTML Attributes", you'll have a good grasp of the basics and be able to apply them to your own projects.
Content
Content is what the user actually sees on the webpage, placed between the opening and closing tags.
The content can be text, a link, an image, or other multimedia.
It can also contain other elements, which we'll touch on soon.
Featured Images: pexels.com

