<h1> - Header tag
<p> - paragraph
Commenting -
<!-- TODO: Remove h1 -->
HTML5 has some elements that identify different content areas. These elements make your HTML easier to read and help with Search Engine Optimization (SEO) and accessibility. The
main
element is used to represent the main content of the body of an HTML document. Content inside themain
element should be unique to the document and should not be repeated in other parts of the document.You can add images to your website by using the
img
element.img
elements have an opening tag without a closing tag. An element without a closing tag is known as a void element. <img>We can add src, alt attributes to our img element. The
alt
attribute's text is used for screen readers to improve accessibility and is displayed if the image fails to load. src has the jpg link to picture.<img src="cat.jpg" alt="A cat">
You can link to another page with the anchor (
a
) element.<a href="<
https://www.freecodecamp.org>">click
here to go to
freeCodeCamp.org
</a>
Target attribute - To open links in a new tab, you can use the
target
attribute on the anchor (a
) element. Thetarget
attribute specifies where to open the linked document.target="_blank"
opens the linked document in a new tab or window.The
section
element is used to define sections in a document, such as chapters, headers, footers, or any other sections of the document. It is a semantic element that helps with SEO and accessibility.To create an unordered list of items, you can use the
ul
element.The
li
element is used to create a list item in an ordered or unordered list.The
figure
element represents self-contained content and will allow you to associate an image with a caption.A figure caption (
figcaption
) element is used to add a caption to describe the image contained within thefigure
element.To place emphasis on a specific word or phrase, you can use the
em
element.The code for an ordered list (
ol
) is similar to an unordered list, but list items in an ordered list are numbered when displayed.The
form
element is used to get information from a user like their name, email, and other details.The
action
attribute indicates where form data should be sent.The
input
element allows you several ways to collect data from a web form. Likeimg
elements,input
elements are a void element and do not need closing tags.Create a text field to get text input from a user by adding the
type
attribute with the valuetext
to theinput
element.Placeholder text is used to give people a hint about what kind of information to enter into an input.
To prevent a user from submitting your form when required information is missing, you need to add the
required
attribute to aninput
element.label
elements are used to help associate the text for aninput
element with theinput
element itself (especially for assistive technologies like screen readers).The
id
attribute is used to identify specific HTML elements. Eachid
attribute's value must be unique from all otherid
values for the entire page.Create radio buttons by setting type both radio buttons can be selected at the same time. To make it so selecting one radio button automatically deselects the other, both buttons must have a
name
attribute with the same value. (While you won't notice this in the browser, doing this makes it easier for a server to process your web form, especially when there are multiple checkboxes.)If you select the
Indoor
radio button and submit the form, the form data for the button is based on itsname
andvalue
attributes. Since your radio buttons do not have avalue
attribute, the form data will includeindoor-outdoor=on
, which is not useful when you have multiple buttons.The
fieldset
element is used to group related inputs and labels together in a web form.fieldset
elements are block-level elements, meaning that they appear on a new line. Nest theIndoor
andOutdoor
radio buttons within afieldset
element, and don't forget to indent the radio buttons.The
legend
element acts as a caption for the content in thefieldset
element. It gives users context about what they should enter into that part of the form.Forms commonly use checkboxes for questions that may have more than one answer. The
input
element with atype
attribute set tocheckbox
creates a checkbox.There's another way to associate an
input
element's text with the element itself. You can nest the text within alabel
element and add afor
attribute with the same value as theinput
element'sid
attribute.In order to make a checkbox checked or radio button selected by default, you need to add the
checked
attribute to it.
<h2>Cat Form</h2>
<form action="<https://freecatphotoapp.com/submit-cat-photo>">
<fieldset>
<legend>Is your cat an indoor or outdoor cat?</legend>
<label><input id="indoor" type="radio" name="indoor-outdoor" value="indoor" checked> Indoor</label>
<label><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label>
</fieldset>
<fieldset>
<legend>What's your cat's personality?</legend>
<input id="loving" type="checkbox" name="personality" value="loving" checked> <label for="loving">Loving</label>
<input id="lazy" type="checkbox" name="personality" value="lazy"> <label for="lazy">Lazy</label>
<input id="energetic" type="checkbox" name="personality" value="energetic"> <label for="energetic">Energetic</label>
</fieldset>
<input type="text" name="catphotourl" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
In order to make a checkbox checked or radio button selected by default, you need to add the
checked
attribute to it.All page content elements that should be rendered to the page go inside the
body
element. However, other important information goes inside thehead
element.The
html
element is the root element of an HTML page and wraps all content on the page. You can also specify the language of your page by adding thelang
attribute to thehtml
element.Add thelang
attribute with the valueen
to the openinghtml
tag to specify that the language of the page is English.All pages should begin with
<!DOCTYPE html>
. This special string is known as a declaration and ensures the browser tries to meet industry-wide specifications.<!DOCTYPE html>
tells browsers that the document is an HTML5 document which is the latest version of HTML.You can set browser behavior by adding
meta
elements in thehead
. Inside thehead
element, nest ameta
element with an attribute namedcharset
. Set to the value toutf-8
which tells the browser how to encode characters for the page. <meta charset = "UTF-8"> charset is attribute and UTF-8 is an encoding value.The
div
element is used mainly for design layout purposes unlike the other content elements you have used. It has an id attribute to specify what kind of content is kept.