Basic HTML | HTML Fundamentals Flashcards
What does the div element represent in HTML?
A flexible container that can be styled and used to group other elements together
The div can be given height, width, and background color using CSS.
Write an example of a basic div element.
<div></div>
This is the simplest form of a div element.
How can a div be utilized without styling?
To hold and group other elements together
For example, a heading and a paragraph can be placed inside a div.
Provide an example of a div containing a heading and a paragraph.
<div><h1>I am a heading</h1><p>I am a paragraph</p></div>
This shows how elements can be grouped within a div.
What is an alternative to using a div for grouping elements?
The section element
The section element has semantic meaning, unlike the div.
What does semantic meaning refer to in HTML?
The meaning of elements that allows browsers to understand their purpose
For example, a section element indicates a thematic grouping.
How does a browser treat a section element?
It recognizes its semantic meaning and understands it as a section
This applies across different devices like desktops and mobiles.
True or False: The div element has semantic meaning.
False
The div is described as a ‘mysterious ghost’ without semantic significance.
What does the id attribute do in HTML?
Adds a unique identifier to an HTML element
How should id names be used in an HTML document?
They should not be used more than once and must always be unique
What symbol is used to reference an id in CSS?
The hash symbol (#)
What characters are allowed in id attribute values?
Letters, digits, underscores, and dashes
True or False: id attribute values can contain spaces.
False
What is the purpose of the class attribute in HTML?
To apply styles to multiple elements without needing uniqueness
How can multiple class names be applied to a single HTML element?
By separating the names with a space
What symbol is used to reference a class in CSS?
The dot symbol (.)
When is it best to use an id versus a class?
Use id for specific elements and class for multiple elements
Fill in the blank: The id attribute value cannot have _______.
spaces
What happens if you use a space in an id attribute value?
Browsers will see the space as part of the id, causing issues
What are the allowed characters for class attribute values?
Letters, digits, underscores, dashes, and spaces
What is the effect of the following CSS rule: #title { color: red; }?
Changes the text color of the element with id ‘title’ to red
What is the example HTML code for a div with a class called ‘box’?
<div></div>
What does the following CSS rule do: .box { width: 200px; height: 200px; border: 2px solid black; }?
Sets width, height, and border properties for elements with class ‘box’
What is an HTML entity?
A set of characters used to represent a reserved character in HTML.