IDs in html Flashcards

(12 cards)

1
Q

What is the primary function of the id attribute in an HTML element?

A

It serves as a unique identifier for that specific element within the HTML document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which two languages commonly use the id attribute to perform a specific task on a particular element?

A

CSS and JavaScript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What symbol is used in CSS to select and style an element by its id?

A

The ‘#’ (hash) symbol is used as a prefix to the id name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

According to the source, what is the most important rule regarding the use of id attributes in an HTML document?

A

An HTML document cannot have two elements with the same id; each id must be unique.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Because ids must be unique, we can style only _____ element at a time using an id selector in CSS.

A

one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In JavaScript, what is the id attribute commonly used for?

A

It is used to access and manipulate a unique HTML element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of using HTML bookmarks with IDs?

A

They allow readers to quickly navigate to specific sections of a long webpage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the first step in creating an HTML bookmark?

A

First, you must create the bookmark, typically by assigning an id to a heading or section element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the second step to make an HTML bookmark functional after it has been created?

A

You must add a link that points to the bookmark’s id.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the correct syntax for a link that jumps to an element with the id ‘title’?

A

The link’s href attribute should be set to ‘#title’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When a user clicks a link pointing to a bookmark, what action does the browser perform?

A

The page will scroll to the location of the element with the corresponding id.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the single main difference between an id and a class in HTML?

A

An id is unique within a page and applies to only one element, whereas a class can be applied to multiple elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly