HTML fundamentals

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What is the primary function of HTML?

  • To add dynamic behavior and interactivity to a webpage.
  • To manage server-side operations for a webpage.
  • To define the structure and content of a webpage. (correct)
  • To style the visual appearance of a webpage.

Which of the following is the correct structure of an HTML element?

  • Content
  • ..Content.. (correct)
  • Content
  • Content

What is the root element in every HTML document?

  • (correct)
  • (correct)
  • (correct)
  • (correct)

Which declaration is required at the beginning of an HTML5 document?

<p>(A), (B), (C), (D)</p> Signup and view all the answers

What is the purpose of HTML attributes?

<p>To provide additional information about HTML elements. (C)</p> Signup and view all the answers

Which of the following is an example of correct HTML for creating a hyperlink?

<p>Click Here (A), Click Here (C), Click Here (D)</p> Signup and view all the answers

Consider this HTML snippet:``What will be displayed in the browser?

<p>My First Heading (D)</p> Signup and view all the answers

Which of the following characters must be escaped in HTML to display correctly?

<p><code>&amp;</code> (D)</p> Signup and view all the answers

Examine the following HTML code:

What would be displayed in the web browser?

<p>The code will result in an error because the element cannot directly contain text. (D)</p> Signup and view all the answers

In HTML, which of the following is the most semantically correct way to represent an abbreviation or acronym?

<p>Using the `` element with the <code>title</code> attribute providing the full expansion. (C)</p> Signup and view all the answers

Which of the following statements accurately describes HTML attributes?

<p>They provide additional information about HTML elements. (C)</p> Signup and view all the answers

What attribute is essential within the <a> tag to create a hyperlink?

<p>href (A)</p> Signup and view all the answers

Which attributes are recommended for the <img> tag?

<p>width and height (B)</p> Signup and view all the answers

What is the primary characteristic of a block-level element in HTML?

<p>It always starts on a new line. (C)</p> Signup and view all the answers

Which of the following is an example of a block-level element?

<p> (A) Signup and view all the answers

What distinguishes an inline element from a block-level element?

<p>An inline element only takes up as much width as necessary. (B)</p> Signup and view all the answers

Which HTML tags are used to define headings?

<h1> to <h6> (B) Signup and view all the answers

Which HTML element is used to define a paragraph?

<p> (B) Signup and view all the answers

Which HTML element is specifically designed for marking up a section of text that is quoted from another source, and is typically rendered with indentation by browsers?

<blockquote> (B) Signup and view all the answers

Consider a scenario where you need to embed an image that, upon being clicked, redirects the user to an external website. Which of the following code snippets would correctly implement this functionality?

<p><code>&lt;a href=&quot;https://example.com&quot;&gt;&lt;img src=&quot;image.jpg&quot;&gt;&lt;/a&gt;</code> (C)</p> Signup and view all the answers

HTML is utilized to dictate the presentation, rather than the structure, of a web page.

<p>False (B)</p> Signup and view all the answers

In HTML, the <html> element must be placed inside the <body> element.

<p>False (B)</p> Signup and view all the answers

The <head> element in HTML is where you place content that is visible to users on the web page.

<p>False (B)</p> Signup and view all the answers

HTML documents must begin with the declaration <!DOCTYPE html>.

<p>True (A)</p> Signup and view all the answers

An HTML element with only a start tag is referred to as a closed element.

<p>False (B)</p> Signup and view all the answers

The <div> tag in HTML is considered a structural element, primarily utilized to define a division or a section in an HTML document.

<p>True (A)</p> Signup and view all the answers

The HTML entity &nbsp; represents a non-breaking space.

<p>True (A)</p> Signup and view all the answers

In HTML, attributes are defined exclusively within the closing tag of an element.

<p>False (B)</p> Signup and view all the answers

In HTML, an empty element is required to have a closing tag for proper rendering by web browsers.

<p>False (B)</p> Signup and view all the answers

The direct ancestor of any HTML element with the lang attribute set to en-GB must always have the lang attribute set to en or en-UK

<p>False (B)</p> Signup and view all the answers

All HTML elements must have at least one attribute.

<p>False (B)</p> Signup and view all the answers

HTML attributes are specified within the closing tag of an element.

<p>False (B)</p> Signup and view all the answers

In HTML, attributes generally appear as name-value pairs, such as style="value".

<p>True (A)</p> Signup and view all the answers

The href attribute in the <a> tag specifies the text that will be displayed as the hyperlink.

<p>False (B)</p> Signup and view all the answers

For optimal rendering, the <img> tag requires both width and height attributes to be specified.

<p>True (A)</p> Signup and view all the answers

Block-level elements are displayed inline by default and only take up as much width as necessary.

<p>False (B)</p> Signup and view all the answers

The <section> tag is an inline element used to define a paragraph.

<p>False (B)</p> Signup and view all the answers

The <h1> tag represents the least important heading on an HTML page.

<p>False (B)</p> Signup and view all the answers

Using the <quotation> tag will indent the quoted text and add citation information.

<p>False (B)</p> Signup and view all the answers

The <hyperlink> tag is the correct HTML element to create hyperlinks.

<p>False (B)</p> Signup and view all the answers

Flashcards

What is HTML?

Hyper Text Markup Language, the standard language for creating web pages. It describes the structure of a web page using elements.

What is ?

It declares the document type and is always the first tag in an HTML document.

< html > element

The root element of an HTML page; it wraps all other elements.

< head > element

Contains meta-information about the HTML document, such as character set, title, styles, and more.

Signup and view all the flashcards

< title > element

Specifies a title for the HTML page (which is shown in the browser's title bar or tab).

Signup and view all the flashcards

< body > element

Defines the document's body and contains all the content of an HTML document (text, images, links, etc.).

Signup and view all the flashcards

< h1 > element

Defines a large heading.

Signup and view all the flashcards

< p > element

Defines a paragraph.

Signup and view all the flashcards

Nested HTML elements

HTML elements can be placed inside other HTML elements.

Signup and view all the flashcards

HTML attributes

Provide additional information about HTML elements; they're always specified in the start tag.

Signup and view all the flashcards

width attribute

Specifies the width of an image, in pixels.

Signup and view all the flashcards

height attribute

Specifies the height of an image, in pixels.

Signup and view all the flashcards

Block-level element

Starts on a new line and takes up the full width available with margins.

Signup and view all the flashcards

Inline element

Does not start on a new line and only takes up as much width as necessary.

Signup and view all the flashcards

tag

Defines a paragraph in an HTML document; a block-level element.

Signup and view all the flashcards

tag

Defines a division or a section in an HTML document; a block-level element.

Signup and view all the flashcards

HTML Headings (

to

)

Titles or subtitles displayed on a webpage. defines the most important heading.

Signup and view all the flashcards

tag

Defines a section that is quoted from another source; Browsers usually indent it.

Signup and view all the flashcards

Web Browsers

Software applications that enable users to view web pages. They interpret HTML code to display content.

Signup and view all the flashcards

HTML Element

The basic unit of HTML. It consists of a start tag, content, and an end tag.

Signup and view all the flashcards

HTML Quotation

Used for short quotations; browsers typically render them inline.

Signup and view all the flashcards

  entity

Used to embed space in your text.

Signup and view all the flashcards

HTML link

Defines a hyperlink to another webpage. The 'href' attribute specifies the URL.

Signup and view all the flashcards

width and height attributes

These attributes should be included to specify the dimensions of the image in pixels.

Signup and view all the flashcards

< div > element

Defines a division or a section in an HTML document.

Signup and view all the flashcards

Study Notes

  • HTML stands for Hyper Text Markup Language.
  • It is the standard markup language for creating web pages
  • HTML describes the structure of a webpage.
  • HTML consists of a series of elements.
  • HTML elements tell the browser how to display the content.
  • HTML elements label pieces of content like "this is a heading", "this is a paragraph", and "this is a link".
  • Web browsers like Chrome, Edge, Firefox, and Safari read HTML documents used to display them correctly.
  • Web browsers utilize HTML tags to determine how the content is displayed.

Simple HTML Document Example

  • <!DOCTYPE html>: This declaration must start all HTML documents
  • <html>: This tag is the root element of an HTML page.
  • <head>: Contains meta-information about the HTML page.
  • <title>: Specifies a title for the HTML page which will appear in the browser's title bar or tab.
  • <body>: Defines the document's body, and is a container for all the visible content, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
  • <h1>: Defines a large heading.
  • <p>: Defines a paragraph.

HTML Page Structure

  • <html> is the root element.
  • <head> contains meta-information like the <title>.
  • <body> contains the content displayed in the browser.
  • The content inside the <body> section will be displayed in a browser.
  • The content inside the <title> element shows in the browser's title bar or tab.

Special Entity Characters

  • HTML uses special characters to display content.
  • &copy; is the code for the copyright symbol.
  • &lt; is the code for "<".
  • &gt; is the code for ">".
  • &amp; is the code for "&".
  • &nbsp; is the code for space.

HTML Documents

  • All HTML documents must start with a <!DOCTYPE html> declaration.
  • The HTML document begins with <html> and ends with </html>.
  • The visible part of the HTML document is between <body> and </body>.

HTML Elements

  • An HTML element is defined by a start tag, some content, and an end tag: <tagname> content </tagname>
  • The HTML element is everything from the start tag to the end tag.
  • Some HTML elements have no content and are called empty elements - for example <br>.
  • Empty elements do not have an end tag.

Nested HTML Elements

  • HTML elements can be nested, meaning elements can contain other elements.
  • All HTML documents consist of nested HTML elements.
  • The example contains four HTML elements: <html>, <body>, <h1>, and <p>.
  • <html> is the root element and defines the whole HTML document, with start and end tags.
  • Inside the <html> element, there is a <body>.

HTML Attributes

  • HTML attributes provide additional information about HTML elements.
  • All HTML elements can have attributes.
  • Attributes provide additional information about elements.
  • Attributes are specified in the start tag.
  • Attributes come in name/value pairs like name="value".
  • The <a> tag defines a hyperlink.
  • The href attribute specifies the URL. For example, <a href="https://www.google.com">Visit google</a>
  • <img> should also contain height and width attributes that specify the height and width of the image <img src="img.jpg" width="500" height="600">

HTML Block and Inline Elements

  • Every HTML element has a default display value, depending on what type of element it is.
  • A block-level element always starts on a new line and the browsers automatically add some space (a margin) before and after the element.
  • Examples of block elements are <p> and <div>.
  • Inline elements do not start on a new line, only taking up as much width as necessary.
  • Two common block elements are <p> and <div>.
  • The <p> element defines a paragraph.
  • The <div> element defines a division or a section.
  • An inline element doesn't start on a new line and only expands as much width as is necessary.
  • <span> is an example of an inline element used within a paragraph
  • Syntax: <span>Hello World</span>

HTML Headings

  • HTML headings are titles or subtitles displayed on a webpage.
  • Headings are defined with the <h1> to <h6> tags.
  • <h1> defines the most important while <h6> is the least important.
  • Example usages: <h1>This is heading 1</h1>, <h2>This is heading 2</h2>, <h3>This is heading 3</h3>

HTML Paragraphs

  • HTML paragraphs are defined with the <p> tag.
  • Example: <p>paragraph text</p>

HTML Blockquote

  • <blockquote> defines a section quoted from another source.
  • Browsers indent <blockquote> elements.
  • Example: <blockquote cite="URL">Text of the quote.</blockquote>

HTML Line Break Element

  • <br> is a line break element.
  • It's a stand-alone tag called a void element in HTML5.
  • It causes the next element or text to display on a new line.

HTML Horizontal Rule Element

  • <hr> is a horizontal rule element.
  • It's a void element.
  • It configures a horizontal line on the page.
  • Use hr to indicate a thematic break at the paragraph level in HTML5.

HTML Phrase Elements

  • These elements indicate the context and meaning of text.
  • They display inline with the text.
  • <b> displays text in bold font.
  • <strong> has strong importance and is also displayed in bold.
  • <i> displays text in italic font.
  • <em> has emphasis and is also displayed in italic font.

HTML Lists

  • HTML lists group a set of related items.
  • Three types: unordered, description, and ordered lists

Unordered HTML List

  • <ul> starts it.
  • <li> begins each list item.
  • List items are marked with bullets by default`.
  • Example:
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
  • Output:
  • Coffee
  • Tea
  • Milk

Ordered HTML List

  • <ol> starts it.
  • <li> tag marks the beginning of each item.
  • List items are marked with numbers by default.
  • Example:
<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>
  • Output:
  1. Coffee
  2. Tea
  3. Milk

HTML Description Lists

  • A description list is a list of terms, with a description of each term.
  • <dl> defines the description list.
  • <dt> defines the term.
  • <dd> describes each term.
  • Example:
<dl>
  <dt>Coffee</dt>
    <dd>black hot drink</dd>
  <dt>Milk</dt>
    <dd>white cold drink</dd>
</dl>
  • Output: Coffee black hot drink Milk white cold drink

HTML Div Element

  • <div> acts as a container for other HTML elements.
  • It defaults to a block element, taking the full available width with line breaks before and after.
  • It can contain other block or inline display elements.
  • Multiple <div> containers are permitted on the same page.

Structural Elements

  • <header> contains the headings for a page.
  • <nav> contains the main navigation links.
  • <main> holds the main content.
  • <footer> contains the footer information.

HTML Tables

  • HTML tables arrange data into rows and columns, best for logically grouped items.
  • <table> creates a table.
  • <tr> creates table rows.
  • <td> creates data cells within the rows, enclosing the actual presented data. For example:
<table>
  <tr>
    <td>Month</td>
    <td>Sales</td>
  </tr>
  <tr>
    <td>January</td>
    <td>$10,000</td>
  </tr>
</table>
  • Each <td> and </tr> closing tags may optionally be omitted, and either form of element is valid.
  • <caption> specifies a descriptive table title; it must immediately follow the opening <table> tag.
  • <th> tags are used for row and column headings. For example:
<table>
  <caption>Monthly Sales Report</caption>
  <tr>
    <th>Month</th>
    <th>Sales</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$10,000</td>
  </tr>
</table>
  • The "colspan" attribute makes a cell span over multiple columns.
  • The "rowspan" attribute makes a cell span over multiple rows.
  • Example of Colspan:
<table>
  <caption>Monthly Sales Report</caption>
  <tr>
    <th colspan="2">Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Abdullah</td>
    <td>Ali</td>
    <td>28</td>
  </tr>
</table>
  • Example of Rowspan:
<table>
  <caption>Monthly Sales Report</caption>
  <tr>
    <th>Day</th>
    <th>Time</th>
    <th>Event</th>
  </tr>
  <tr>
    <td rowspan="2">Monday</td>
    <td>09:00 AM</td>
    <td>Meeting</td>
  </tr>
  <tr>
    <td>10:00 AM</td>
    <td>Workshop</td>
  </tr>
</table>
  • <thead> and <tfoot>: tables can include special header and footer rows using these tags for additional table information.
  • <tbody> encloses regular table rows when <thead> and/or <tfoot> are used.
  • Multiple <tbody> elements can group rows into sections for long tables.
  • When printed, headers and footers can repeat on each page.
  • <thead> must appear before <tbody>, but after <caption> (if present) and this enhances table readability & format

Writing Valid HTML

  • Check for syntax errors.
  • Benefit: valid code results in more consistent browser display.

HTML Validation Tools

  • W3C HTML Validation Tool: http://validator.w3.org or http://validator.w3.org/nu.
  • Additional HTML5 Validation Tool: http://html5.validator.nu.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Chapter 01 HTML PDF

More Like This

Use Quizgecko on...
Browser
Browser