Can HTML name be anything?

Can the name of html code be anything? here is the example:

<label for="indoor">
      <input id="indoor" type="radio" name="indoor-outdoor">indoor
    </label>

Can “label” here be changed to literally any text like a variable in Python?
or here…

<p>Click here to view more <a href="#">cat photos</a>.</p>

Can “p” and “a” be named literally to any text like a variable in Python?an

1 Like

no. HTML have only the tags that are defined. you can try to rename those tags and see, it will not work.

1 Like

No, they aren’t variables. They are specific names that mean different things so that the browser can take them and render a page. You can’t just give them arbitrary names, that defeats the point.

Technically you can name them anything you like, but that’s pointless as [normally] the browser will recognise that they aren’t correct, that it doesn’t understand what they are, and turn them into a <div> tag. You can also create new elements using a browser API called Web Components. In that case the have to be named with a hyphen, like <foo-bar>, but that involves a fair amount of work to create them using JavaScript, as you need to define how the element should behave in the browser.

2 Likes

oh okay, thank you so much, I recently came from Python, that’s why I got confused, thanks!