Introduction to HTML

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which HTML tag is used to embed internal CSS within an HTML document?

  • `<div>`
  • `<css>`
  • `<link>`
  • `<style>` (correct)

Which of the following is NOT a self-closing HTML tag?

  • `<p>` (correct)
  • `<br>`
  • `<img>`
  • `<hr>`

In HTML, what attribute is used to provide alternative text for an image if it fails to load?

  • src
  • href
  • alt (correct)
  • title

Which attribute is used to link an external CSS file to an HTML document?

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

Given the CSS rule body { font-size: 16px; } and inline style <p style="font-size: 18px;">Text</p>, what will be the font size of the text inside the paragraph?

<p>18px (D)</p> Signup and view all the answers

What is the correct HTML for inserting a line break?

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

In CSS, what does the * selector target?

<p>All HTML elements on the page. (C)</p> Signup and view all the answers

Which of the following CSS properties is used to change the text color of an element?

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

What is the purpose of the <div> tag in HTML?

<p>To define a division or a section in an HTML document (A)</p> Signup and view all the answers

In CSS, which selector has a higher specificity: a class selector or an ID selector?

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

What is the correct way to create a hyperlink in HTML?

<p><code>&lt;a href=&quot;http://example.com&quot;&gt;Example&lt;/a&gt;</code> (C)</p> Signup and view all the answers

In CSS, what is the purpose of the padding property?

<p>To add space inside the border of an element. (A)</p> Signup and view all the answers

What does the <!DOCTYPE html> declaration do?

<p>It tells the browser that the document is written in HTML5. (B)</p> Signup and view all the answers

In CSS, how do you select all <li> elements inside an unordered list (<ul>)?

<p>ul li { } (A)</p> Signup and view all the answers

You have the following CSS:

p {
  color: blue;
}

.highlight {
  color: red;
}

and HTML:

<p class="highlight">This is a paragraph.</p>

What color will the paragraph text be?

<p>Red (C)</p> Signup and view all the answers

What is the purpose of the box-sizing property in CSS?

<p>To control how the width and height of an element are calculated, including padding and border. (A)</p> Signup and view all the answers

Which of the following is the correct way to apply inline CSS to an HTML element?

<p><code>&lt;p style=&quot;color: blue;&quot;&gt;</code> (A)</p> Signup and view all the answers

In HTML, which tag is used to define the title of a webpage that appears in the browser tab?

<p><code>&lt;title&gt;</code> (C)</p> Signup and view all the answers

In CSS, what is the effect of using !important in a style declaration?

<p>It ensures the rule is applied regardless of specificity. (B)</p> Signup and view all the answers

How can you target all <p> tags that are direct children of a <div> with the ID 'container'?

<p><code>div#container &gt; p</code> (A)</p> Signup and view all the answers

What is the correct HTML tag for inserting a video?

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

What is the tag for creating an ordered list?

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

What is the HTML tag for creating a new table?

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

If you have two conflicting CSS rules targeting the same element, one defined in an external stylesheet and the other as an inline style, which rule will be applied?

<p>The inline style. (A)</p> Signup and view all the answers

Which of the following is the correct way to use the height attribute in HTML to set the height of an image to 100 pixels?

<p><code>&lt;img src=&quot;image.jpg&quot; height=&quot;100px&quot;&gt;</code> (C)</p> Signup and view all the answers

In CSS, how do you specify the font family for an element?

<p>font-family: (A)</p> Signup and view all the answers

If you set box-sizing: border-box; on an element with width: 200px;, padding: 20px;, and border: 5px solid black;, what will be the total rendered width of the element?

<p>200px (D)</p> Signup and view all the answers

What is the purpose of the span tag?

<p>Inline container for styling (C)</p> Signup and view all the answers

In what section do you link an external CSS file?

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

Flashcards

What does HTML stand for?

Hyper-Text Markup Language, the standard language for creating web pages.

What are self-closing tags?

Tags that don't require a closing tag.

What is an attribute?

Provides additional information about an HTML element.

What does the class attribute do?

Specifies a class name, allowing CSS to target multiple elements.

Signup and view all the flashcards

What is the src attribute?

Used in <img> and <video> tags to specify the source file.

Signup and view all the flashcards

What is the alt attribute?

Used in <img> tags to provide alternative text if the image fails to load.

Signup and view all the flashcards

What is the href attribute?

Used in <a> and <link> tags to specify the URL.

Signup and view all the flashcards

What is the rel attribute?

Specifies the type of relationship of the linked document.

Signup and view all the flashcards

What is the style attribute?

Used to embed CSS directly within an HTML tag.

Signup and view all the flashcards

What does the height attribute do?

Specifies the height of an element.

Signup and view all the flashcards

What does the width attribute do?

Specifies the width of an element.

Signup and view all the flashcards

What is CSS?

Cascading Style Sheets; used to style HTML elements.

Signup and view all the flashcards

What does the * (universal) selector do?

Targets all elements in the HTML document.

Signup and view all the flashcards

What are the main types of CSS selectors?

Elements (tags), Classes, IDs.

Signup and view all the flashcards

What happens when CSS specificities are tied?

The attribute further down in the CSS code will be applied.

Signup and view all the flashcards

What does !important do in CSS?

Overrides all other CSS declarations.

Signup and view all the flashcards

What does the CSS property font-size do?

Specifies the font size of text.

Signup and view all the flashcards

What does the CSS property font-family do?

Specifies the font family (e.g., Arial, Times New Roman).

Signup and view all the flashcards

What does the CSS property color do?

Specifies the text color.

Signup and view all the flashcards

What does the CSS property background-color do?

Specifies the background color of an element.

Signup and view all the flashcards

What does the CSS property height do?

Specifies the height of an element.

Signup and view all the flashcards

What does the CSS property width do?

Specifies the width of an element.

Signup and view all the flashcards

What does the CSS property padding do?

Specifies space around the content, inside the border.

Signup and view all the flashcards

What does the CSS property margin do?

Specifies space outside the border.

Signup and view all the flashcards

What does the CSS property border do?

Applies a border to an element; requires width, style, and color.

Signup and view all the flashcards

What does the CSS property box-sizing do?

Determines how the total width and height of an element are calculated.

Signup and view all the flashcards

What does box-sizing: border-box do?

Adds the padding and border within the specified width & height.

Signup and view all the flashcards

What is the <link> tag used for?

Links to external CSS files.

Signup and view all the flashcards

What does the <ul> tag do?

Creates an unordered (bulleted) list.

Signup and view all the flashcards

What does the <ol> tag do?

Creates an ordered (numbered) list.

Signup and view all the flashcards

Study Notes

  • HTML, or Hyper-Text Markup Language, structures web page content.
  • HTML tags begin with "<" and define the element type.
  • Most HTML tags require open and closing tags.

HTML Document Structure:

  • Documents start and end with <html></html> tags.
  • The <head> section contains webpage information not displayed on the page.
    • The <title> tag within <head> specifies the page title shown in the browser tab.
    • The <style> tag in <head> embeds CSS, known as "internal CSS".
  • The <body> section holds the visible content.
    • <p> creates paragraphs.
    • <h1> to <h6> create headings of varying sizes, with <h1> being the largest.
    • <div> creates containers/boxes.
    • <b> bolds text.
    • <i> italicizes text.
    • <video> embeds video content.
    • <a> (anchor tag) creates hyperlinks.
    • <ul> and <ol> create unordered (bulleted) and ordered (numbered) lists, respectively.
    • <li> denotes a list item within <ul> or <ol>.
    • <span> selects a section of text for styling.

Self-Closing Tags:

  • Self-closing tags do not have a closing tag.
  • <!DOCTYPE html> declares HTML5.
  • <link> links external CSS files (in the <head>).
  • <br> inserts a line break.
  • <hr> creates a horizontal line.
  • <img> inserts an image.
  • <source> in <video> or <audio> specifies the media file.

HTML Elements

  • Consist of the opening tag, closing tag, and content.

HTML Attributes

  • Attributes modify HTML elements, added to the opening tag.
  • class="class_name" specifies a class, allowing multiple space-separated class names.
  • id="id_name" specifies a unique ID.
  • src="image.jpg" provides the source URL for images (<img>) or media (<video>, <audio>).
  • alt="alternative text" provides alternative text for images if they fail to load.
  • href="style.css" links to another document (<a>, <link>).
  • rel="stylesheet" defines the relationship of the linked document (<link>).
  • style="color: red;" applies inline CSS.
  • height="360px" sets the height of an element.
  • width="240px" sets the width of an element.

CSS (Cascading Style Sheets)

  • CSS styles HTML elements to control their appearance.
  • CSS uses selectors to target HTML elements:
    • Elements (tags).
    • Classes.
    • IDs.
    • * is a universal selector targeting all elements.

Multiple Selectors

  • Target multiple elements by separating selectors with commas (e.g., p, ul, div).

Combining Selectors

  • Combining selectors increases specificity without spaces (e.g. p#p1.para.top).
  • Child elements are targeted using spaces (e.g., ul ol) or the direct child selector > (e.g. ul > ol).

Specificity

  • Conflicting styles are resolved by the most specific selector.
  • If specificity is tied, the later declaration wins.
  • Specificity ranking (lowest to highest):
    • Elements (tags).
    • Classes.
    • :nth-child() pseudo-selector.
    • IDs.
    • Inline styling (style attribute).
    • !important overrides all other CSS.

Common CSS Properties:

  • font-size sets text size (pixels).
  • font-family sets the font (e.g., Arial).
  • color sets text color (name, hex, RGB).
  • background-color sets background color.
  • height sets element height (pixels).
  • width sets element width (pixels).
  • padding adds space around content, increasing element size.
    • One value: applies to all sides.
    • Two values: top/bottom, left/right.
    • Three values: top, left/right, bottom.
    • Four values: top, right, bottom, left (clockwise).
    • Specific sides can be set with padding-top, padding-bottom, padding-left, and padding-right.
  • margin adds space outside the border, not affecting element size.
    • Margin values behave like padding values.
  • border adds a border: specify width, style (e.g., solid), and color.
  • box-sizing controls how width and height are calculated.
    • content-box (default) sets width/height for content, padding/border increase total size.
    • border-box includes padding/border within specified width/height.

Studying That Suits You

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

Quiz Team

More Like This

HTML: The Building Block of Web Pages
6 questions
Web Design Unit 2: Intro to HTML
12 questions
Web Development: History and Evolution
12 questions
Use Quizgecko on...
Browser
Browser