HTML5 Flashcards
declaration defines that this document is an HTML5 document
declaration defines that this document is an HTML5 document
element is the root element of an HTML page
element contains meta information about the HTML page
element specifies a title for the HTML page (which is shown in the browser’s title bar or in the page’s tab)
element defines the document’s body, and is a container for all the visible contents, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
<h1></h1>
element defines a large heading, can have up to 6, h1, h2, h3, etc each gets smaller, it’s good practice to only use one h1
<p></p>
element defines a paragraph
What is an HTML Element?
An HTML element is defined by a start tag, some content, and an end tag:
Content goes here…
The HTML element is everything from the start tag to the end tag:
Web Browsers
The purpose of a web browser (Chrome, Edge, Firefox, Safari) is to read HTML documents and display them correctly.
A browser does not display the HTML tags, but uses them to determine how to display the document:
<a></a>
HTML links are defined with the <a> tag:</a>
Example
</a><a>This is a link</a>
<img></img>
HTML images are defined with the <img></img> tag.
The source file (src), alternative text (alt), width, and height are provided as attributes:
Example
<img></img>
<br></br>
The <br></br> tag defines a line break, and is an empty element without a closing tag:
HTML is Not Case Sensitive
HTML tags are not case sensitive: <p> means the same as </p><p>.
The HTML standard does not require lowercase tags, but W3C recommends lowercase in HTML, and demands lowercase for stricter document types like XHTML.</p>
HTML Attributes
All HTML elements can have attributes
Attributes provide additional information about elements
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name=”value”
The href Attribute
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to:</a>
Example
</a><a>Visit W3Schools</a>
The src Attribute
The <img></img> tag is used to embed an image in an HTML page. The src attribute specifies the path to the image to be displayed:
Example
<img></img>
There are two ways to specify the URL in the src attribute:
1. Absolute URL - Links to an external image that is hosted on another website. Example: src=”https://www.w3schools.com/images/img_girl.jpg”.2.
Relative URL - Links to an image that is hosted within the website. Here, the URL does not include the domain name. If the URL begins without a slash, it will be relative to the current page. Example: src=”img_girl.jpg”. If the URL begins with a slash, it will be relative to the domain. Example: src=”/images/img_girl.jpg”.
The width and height Attributes for images
The <img></img> tag should also contain the width and height attributes, which specifies the width and height of the image (in pixels):
Example
<img></img>
The alt Attribute
The required alt attribute for the <img></img> tag specifies an alternate text for an image, if the image for some reason cannot be displayed. This can be due to slow connection, or an error in the src attribute, or if the user uses a screen reader.
Example
<img></img>
The style Attribute
The style attribute is used to add styles to an element, such as color, font, size, and more.
Example
<p>This is a red paragraph.</p>
The lang Attribute
You should always include the lang attribute inside the tag, to declare the language of the Web page. This is meant to assist search engines and browsers.
The following example specifies English as the language:
…
Country codes can also be added to the language code in the lang attribute. So, the first two characters define the language of the HTML page, and the last two characters define the country.
The following example specifies English as the language and United States as the country:
…
The title Attribute
The title attribute defines some extra information about an element.
The value of the title attribute will be displayed as a tooltip when you mouse over the element:
Example
<p>This is a paragraph.</p>
Single or Double Quotes?
Double quotes around attribute values are the most common in HTML, but single quotes can also be used.
In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes:
<p>
Or vice versa:
</p>
<p></p>
Bigger Headings
Each HTML heading has a default size. However, you can specify the size for any heading with the style attribute, using the CSS font-size property:
Example
<h1>Heading 1</h1>
tag defines a thematic break in an HTML page, and is most often displayed as a horizontal rule. The
element is used to separate content (or define a change) in an HTML page: ``` Example
This is heading 1
This is some text.
This is heading 2
This is some other text.
``` The
tag is an empty tag, which means that it has no end tag.
element defines a line break. Use
if you want a line break (a new line) without starting a new paragraph: Example
This is
a paragraph
with line breaks.
tag is an empty tag, which means that it has no end tag.
My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me.
Element The HTMLelement defines preformatted text. The text inside aelement is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks: ExampleMy Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me.
This is a heading
This is a paragraph.
This is a heading
This is a paragraph.
This is a heading
This is a paragraph.
This is a heading
This is a paragraph.
Centered Heading
Centered paragraph.
Do not forget to buy milk today.
My favorite color is blue red.
My favorite color is blue red.
This is subscripted text.
This is superscripted text.
for Quotations
element defines a section that is quoted from another source. Browsers usually indentelements. ExampleHere is a quote from WWF's website:
For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.
WWF's goal is to: Build a future where people live in harmony with nature.
The WHO was founded in 1948.
Visit us at:
Example.com
Box 564, Disneyland
USA ```
The Scream by Edvard Munch. Painted in 1893.
Hello World
Lorem ipsum...
Ut wisi enim...
Hello World
Hello World
Hello World
...
...
...
The following two...
...
element to blue, and the text color of the
element to red: Example
A Blue Heading
A red paragraph.
elements (on that page) to blue, and the text color of ALL the
elements to red. In addition, the page will be displayed with a "powderblue" background color: ``` Example