1. What does the <h1> tag do?
The <h1> tag defines a heading. The tags <h1> to <h6> define headings from largest to smallest.
<h1>This is a heading</h1>
Full lesson: Html basic
45 questions about HTML with short answers and code. Each answer links to a full lesson on this site. Free, with no signup and no ads.
The <h1> tag defines a heading. The tags <h1> to <h6> define headings from largest to smallest.
<h1>This is a heading</h1>
Full lesson: Html basic
The <p> tag defines a paragraph. Each <p> tag starts a new paragraph.
<p>This is a paragraph.</p>
Full lesson: Html basic
Use the <a> tag to make a link. Put the link address in the href attribute.
<a href="https://www.example.com">This is a link</a>
Full lesson: Html basic
The <!DOCTYPE html> declaration marks the document as HTML5. It goes on the first line of the page.
<!DOCTYPE html>
Full lesson: Html intro
The <head> element contains document metadata. It can hold the title, the character set, styles, and scripts.
<head>
<meta charset="utf-8">
<title>Example</title>
</head>
Full lesson: Html intro
Use the <ul> tag to make an unordered list. Put each item in an <li> tag.
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
Full lesson: Html lists
Use the <img> tag to show an image. Put the image address in the src attribute.
<img src="photo.jpg" alt="A photo">
Full lesson: Html images
Use the <tr> tag to make a table row. Use the <td> tag to make a data cell in the row.
<table>
<tr><td>A</td><td>B</td></tr>
</table>
Full lesson: Html tables
Use the style attribute to add CSS to one element. This is called an inline style.
<p style="color:blue;margin-left:20px;">This is a paragraph.</p>
Full lesson: Html css
A URL is a Uniform Resource Locator. A browser uses a URL to request a page from a web server.
Full lesson: Html url
Use the <form> tag to make a form. Put input fields inside the form element.
<form action="/submit">
<input type="text" name="name">
</form>
Full lesson: Html forms
Use the <iframe> tag to show one page inside another page. Put the page address in the src attribute.
<iframe src="demo_iframe.htm" width="200" height="200"></iframe>
Full lesson: Html iframes
Use the <svg> tag to draw SVG graphics in HTML5. The <circle> tag draws a circle.
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" fill="red"></circle>
</svg>
Full lesson: Html5 svg
The page has no declared character set. Add the meta charset tag to the head to fix the text.
<meta charset="utf-8">
Full lesson: Html tutorial
The src value is wrong or the file is in a different folder. Check the image path in the src attribute.
<img src="images/photo.jpg" alt="A photo">
Full lesson: Html images
A block element starts on a new line. The browser also puts a line break after it. Common examples are <h1>, <p>, <ul>, and <table>.
<p>This is a block element.</p>
Full lesson: Html blocks
An inline element does not start on a new line. It sits inside the text flow. Common examples are <b>, <a>, <img>, and <td>.
<p>This text is <b>bold</b> inside a line.</p>
Full lesson: Html blocks
The <div> element groups other elements. It is a block-level container. It has no special meaning by itself.
<div>
<h1>Title</h1>
<p>Text</p>
</div>
Full lesson: Html blocks
HTML colors mix red, green, and blue values. You can write a hex code or an RGB value. Each value goes from 0 to 255.
<p style="color:#FF0000;">Red text</p>
Full lesson: Html colors
Use the <video> element with the controls attribute. Add <source> tags for each file format. The browser picks a format that it can play.
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
</video>
Full lesson: Html videos
Use the <audio> element with the controls attribute. Add a <source> tag for the audio file. The browser shows a player on the page.
<audio controls>
<source src="horse.ogg" type="audio/ogg">
</audio>
Full lesson: Html5 audio
XHTML is HTML written in XML format. It is a stricter and cleaner version of HTML 4.01. All major browsers support XHTML.
Full lesson: Html xhtml
SVG means Scalable Vector Graphics. It defines vector graphics for the web in XML format. An SVG image keeps its quality when you zoom in.
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" fill="red" />
</svg>
Full lesson: Html5 svg
A plugin is a small program that adds functions to a browser. You can load plugin content with the <object> or <embed> tag. These tags hold non-HTML resources.
<embed src="movie.swf" width="320" height="240">
Full lesson: Html sounds
The <base> tag sets the default link target for all links. It goes inside the <head> element. The browser uses it for relative URLs.
<head>
<base href="https://www.example.com/">
</head>
Full lesson: Html head
The action attribute sets the target URL for the form data. A wrong or missing action sends data to the wrong place. Check the action value first.
<form action="/save" method="post">
<input type="text" name="name">
</form>
Full lesson: Html forms
The href attribute holds the link target. A wrong path or a missing href breaks the link. Check the href value and the file path.
<a href="page.html">Go to page</a>
Full lesson: Html links
Browsers support different audio formats. One source file can fail in another browser. Add more than one <source> tag for safety.
<audio controls>
<source src="sound.ogg" type="audio/ogg">
<source src="sound.mp3" type="audio/mpeg">
</audio>
Full lesson: Html5 audio
The controls attribute adds the play and pause buttons. Without it, the user cannot start the video. Add the controls attribute to the <video> tag.
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
</video>
Full lesson: Html videos
Some old browsers do not support inline SVG. The browser then shows only the fallback text. Test the page in a modern browser.
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" fill="blue" />
</svg>
Full lesson: Html5 svg
The <title> element sets the page title. The browser shows the title in the tab. Search engines use the title in results.
<head>
<title>My Page</title>
</head>
Full lesson: Html head
Use the <ol> element to make an ordered list. Put <li> elements inside the <ol> element. The browser adds numbers to the items.
<ol>
<li>First</li>
<li>Second</li>
</ol>
Full lesson: Html lists
Add target="_blank" to the <a> tag. The browser opens the link in a new tab. The rel="noopener" attribute adds safety.
<a href="https://example.com" target="_blank" rel="noopener">Open</a>
Full lesson: Html links
The <meta> tag gives data about the page. The charset attribute sets the character encoding. The viewport setting helps on mobile screens.
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Full lesson: Html head
Use the <caption> element inside the <table> element. Put the <caption> element first. The browser shows the caption above the table.
<table>
<caption>Sales</caption>
<tr><td>10</td></tr>
</table>
Full lesson: Html tables
Use the <label> element with the for attribute. Set the for value to the input id. A click on the label focuses the input.
<label for="name">Name</label>
<input type="text" id="name" name="name">
Full lesson: Html forms
Use the <video> element with the controls attribute. Add one <source> element for each file format. The browser picks a format that it can play.
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
</video>
Full lesson: Html videos
Use the <audio> element with the controls attribute. Add a <source> element for the audio file. The browser shows a player with play and pause buttons.
<audio controls>
<source src="horse.ogg" type="audio/ogg">
</audio>
Full lesson: Html5 audio
Use the <object> tag to add external content. The data attribute sets the file. The browser shows the content in a box.
<object data="movie.mp4" width="320" height="240"></object>
Full lesson: Html object
Use lowercase letters for tag names. This is the HTML5 convention. Lowercase names are easy to read and to check.
<p>Hello</p>
Full lesson: Html5 syntax
The table has no border by default. Add the border attribute or CSS to show a border. The border attribute is a quick fix.
<table border="1">
<tr><td>Cell</td></tr>
</table>
Full lesson: Html tables
The <li> element is outside a list element. Put each <li> element inside a <ul> or <ol> element. The browser then shows the bullet or number.
<ul>
<li>Item</li>
</ul>
Full lesson: Html lists
The for value does not match the input id. Set the for value to the exact input id. A click on the label then focuses the input.
<label for="email">Email</label>
<input type="email" id="email">
Full lesson: Html forms
The video has only one file format. Add more <source> elements for other formats. The browser then picks a format that it can play.
<video controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.webm" type="video/webm">
</video>
Full lesson: Html videos
Internet Explorer 8 and earlier versions do not support the <audio> element. Add fallback content inside the <audio> element. The fallback text shows in old browsers.
<audio controls>
<source src="horse.ogg" type="audio/ogg">
Your browser does not support audio.
</audio>
Full lesson: Html5 audio