<header>
, <footer>
, <article>
, <section>
and <figure>
are added.
A semantic element clearly describes its meaning to both the browser and the developer In HTML there are some semantic elements that can be used to define different parts of a web page
<section>
Element
<section>
element can be used:
<section>
<h1>WWF</h1>
<p>
The World Wide Fund for Nature (WWF) is an international organisation
working on issues regarding the conservation, research and restoration of
the environment, formerly named the World Wildlife Fund. WWF was founded in
1961.
</p>
</section>
<article>
Element
<article>
element specifies independent, self-contained content.<article>
tag is used to represent an article.<article>
is independent from the other content of the site (even though it can be related).<article>
element can be used:
<article>
<h2>Google Chrome</h2>
<p>
Google Chrome is a web browser developed by Google, released in 2008. Chrome
is the world's most popular web browser today!
</p>
</article>
Nesting <article>
in <section>
or Vice Versa?
<article>
element specifies independent, self-contained content.<section>
element defines section in a document.<article>
elements containing <section>
elements, and <section>
elements containing <article>
elements.<header>
Element
<header>
element contains the section heading as well as other content, such as navigation links, table of contents, etc.<header>
element typically contains:<header>
elements in one HTML document. However, <header>
cannot be placed within a <footer>
, <address>
or another <header>
element.<header>
<h1>What Does WWF Do?</h1>
<p>WWF's mission:</p>
</header>
<footer>
Element
<footer>
element defines a footer for a document or section.<footer>
element typically contains:
<footer>
elements in one document<footer>
<p>Author: Hege Refsnes</p>
<p><a href="mailto:hege@example.com">hege@example.com</a></p>
</footer>
<nav>
Element
<nav>
tag is used to declare the navigational section in HTML documents.<nav>
<a href="/html/">HTML</a>
<a href="/css/">CSS</a>
<a href="/js/">JavaScript</a>
<a href="/jquery/">jQuery</a>
</nav>
<aside>
Element
<aside>
element defines some content aside from the content it is placed in (like a sidebar).<aside>
tag is used to describe the main object of the web page in a shorter way like a highlighter.<aside>
tag contains mainly author information, links, related content and so on<aside>
content should be indirectly related to the surrounding content.<aside>
<h4>Epcot Center</h4>
<p>
Epcot is a theme park at Walt Disney World Resort featuring exciting
attractions, international pavilions, award-winning fireworks and seasonal
special events.
</p>
</aside>
<figure>
and <figcaption>
Elements
<figure>
tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.<figcaption>
tag defines a caption for a <figure>
element.<figcaption>
element can be placed as the first or as the last child of a <figure>
element.<img>
element defines the actual image/illustration.<figure>
<img src="pic_trulli.jpg" alt="Trulli" style="width:100%" />
<figcaption>Fig.1 - Trulli, Puglia, Italy.</figcaption>
</figure>
<video>
tag is used to embed video content in a document, such as a movie clip or other video streams.<video width="320" height="240" controls autoplay loop muted poster=”url/location” >
<source src="interstellar.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<video>
tag contains one or more <source>
tags with different video sources. The browser will choose the first source it supports.<video>
and </video>
tags will only be displayed in browsers that do not support the element.controls
: Specifies that video controls should be displayed (such as a play, pause and volume buttons).autoplay
: Specifies that the video will start playing as soon as it is readyloop
: Specifies that the video will start over again, every time it is finished.muted
: Specifies that the audio output of the video should be muted.poster
: Specifies an image to be shown while the video is downloading, or until the user hits the play button (thumbnail).<audio>
element<audio controls autoplay loop muted>
<source src="horse.mp3" type="audio/mp3" />
Your browser does not support the audio element.
</audio>
<audio>
tag is used to embed sound content in a document, such as music or other audio streams.<audio>
tag contains one or more <source>
tags with different audio sources. The browser will choose the first source it supports.<audio>
and </audio>
tags will only be displayed in browsers that do not support the <audio>
element.autoplay
: Specifies that the audio will start playing as soon as it is readycontrols
: Specifies that audio controls should be displayed (such as a play/pause button etc)loop
: Specifies that the audio will start over again, every time it is finishedmuted
: Specifies that the audio output should be mutedAdvantages:
SVG Rectangle:
<svg width="400" height="110">
<rect
width="300"
height="100"
style="fill:rgb(0,0,255); stroke-width:3;
stroke:rgb(0,0,0)"
/>
</svg>
width
and height
attributes of the <rect>
element define the height and the width of the rectangleSVG Circle:
<svg height="100" width="100">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>
cx
and cy
attributes define the x and y coordinates of the center of the circle.cx
and cy
are omitted, the circle's center is set to (0,0)r
attribute defines the radius of the circleSVG Ellipse:
<svg height="140" width="500">
<ellipse
cx="200"
cy="80"
rx="100"
ry="50"
style="fill:yellow;stroke:purple;stroke-width:2"
/>
</svg>
cx
attribute defines the x coordinate of the center of the ellipsecy
attribute defines the y coordinate of the center of the ellipserx
attribute defines the horizontal radiusry
attribute defines the vertical radiusSVG Line:
<svg height="210" width="500">
<line
x1="0"
y1="0"
x2="200"
y2="200"
style="stroke:rgb(255,0,0);
stroke-width:2"
/>
</svg>
x1
attribute defines the start of the line on the x-axisy1
attribute defines the start of the line on the y-axisx2
attribute defines the end of the line on the x-axisy2
attribute defines the end of the line on the y-axisSVG Polygon:
<svg height="210" width="500">
<polygon
points="200,10 250,190 160,210"
style="fill:lime;stroke:purple;stroke-width:1"
/>
</svg>
points
attribute defines the x and y coordinates for each corner of the polygonSVG Polyline:
<svg height="200" width="500">
<polyline
points="20,20 40,25 60,40 80,120 120,140 200,180"
style="fill:none;stroke:black;stroke-width:3"
/>
</svg>
points
attribute defines the list of points (pairs of x and y coordinates) required to draw the polylineInput Types:
<input type="button" />
<input type="checkbox" />
<input type="color" />
<input type="date" />
<input type="email" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="month" />
<input type="number" />
<input type="password" />
<input type="radio" />
<input type="range" />
<input type="reset" />
<input type="submit" />
<input type="tel" />
<input type="text" />
<input type="time" />
<input type="url" />
<input type="week" />
Input Restrictions:
Attribute | Description |
---|---|
checked | Specifies that an input field should be pre-selected when the page loads (for type="checkbox" or type="radio") |
disabled | Specifies that an input field should be disabled |
max | Specifies the maximum value for an input field |
maxlength | Specifies the maximum number of character for an input field |
min | Specifies the minimum value for an input field |
pattern | Specifies a regular expression to check the input value against |
readonly | Specifies that an input field is read only (cannot be changed) |
required | Specifies that an input field is required (must be filled out) |
size | Specifies the width (in characters) of an input field |
step | Specifies the legal number intervals for an input field |
value | Specifies the default value for an input field |
placeholder
Attribute:
<form>
<label for="phone">Enter a phone number:</label>
<input type="text" id="phone" name="phone" placeholder="123-45-678" />
</form>
required
Attribute:
required
attributerequired
attribute specifies that an input field must be filled out before submitting the form.<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required />
</form>
HTML Form Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Form</title>
</head>
<body>
<form
action="/submit"
method="post"
enctype="multipart/form-data"
autocomplete="on"
novalidate
>
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input
type="text"
id="name"
name="name"
placeholder="Enter your name"
required
autofocus
maxlength="50"
pattern="[A-Za-z\s]+"
title="Only letters and spaces are allowed"
/>
<label for="email">Email:</label>
<input
type="email"
id="email"
name="email"
placeholder="Enter your email"
required
maxlength="50"
/>
<label for="password">Password:</label>
<input
type="password"
id="password"
name="password"
placeholder="Enter your password"
required
minlength="8"
maxlength="20"
/>
<label for="dob">Date of Birth:</label>
<input
type="date"
id="dob"
name="dob"
required
min="1900-01-01"
max="2024-04-12"
/>
<label>Gender:</label>
<input type="radio" id="male" name="gender" value="male" required />
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female" />
<label for="female">Female</label>
<input type="radio" id="other" name="gender" value="other" />
<label for="other">Other</label>
<label for="bio">Bio:</label>
<textarea
id="bio"
name="bio"
rows="4"
cols="50"
maxlength="250"
placeholder="Write something about yourself"
></textarea>
<label for="avatar">Avatar:</label>
<input type="file" id="avatar" name="avatar" accept="image/*" />
<label for="terms">Agree to terms:</label>
<input type="checkbox" id="terms" name="terms" required />
<label for="subscription">Subscribe to newsletter:</label>
<input type="checkbox" id="subscription" name="subscription" checked />
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</fieldset>
</form>
</body>
</html>
Made By SOU Student for SOU Students