Question about HTML forms

I’m currently brushing up on HTML that I don’t use as often and learning new code, so go easy on me with the language in the responses as I’m still familiarizing myself with terms and new info.

I’m learning about values and inputs in forms and was becoming confused after I learned about Password, Number, and Range Inputs all having input type=“range/password/number” name=“item” id=“item”. I caught on slightly with those and thought, "Great! Id and names both have the same title for these three inputs. Then I began learning about checkbox inputs. I’m slowly catching on to why a value is included, but my question is why are the name and id no longer named the same thing? Here is some code I was learning from the courses:

label for=“pepperoni”>Pepperoni</label
input type=“checkbox” id=“pepperoni” name=“topping” value=“pepperoni”

I’m confused as to why the id and name no longer match when having the checkbox input? Thanks so much for your help.

The name and id attributes are two different attributes and can or can not be the same. This isn’t determined by the type of form you use. In fact, these attributes’ uses aren’t limited to form inputs and are used with other elements as well.

The name attribute is the name you assign to a certain element. More on the attribute here and its use in forms here.

The id attribute is an identifier, unique for each element, which can be referenced for use, for example in CSS or a script. More on the attribute here.

Welcome to the forums!