<form> Confusion

Hi, I don’t know what value ,name , id and for do or what where they are validating

        <input id="animal-1" name="animal-1" type="text" required>```

Hey there @dinnosam!! Welcome to the Codecademy forums!! :grinning:

The value attribute specifies the value an element will send, for example if you submit:
<input type="text" value="Cat">

Than whatever code reads the input, will perceive it as the string “Cat”

The id attribute is used both for styling with CSS and for adding code such as JS:

  post = getElementById('element')

  #element { 
    color: red;

<input id="element" type="text">
  Random text that is part of a CC forum example!

The text in the <input> is now red, and the JavaScript element post is now equal to the <input>.

The for attribute is usually used to associate a element such as <label> with another element:

<label for="cows">Do you like cows?</label>
<input name="cows" type="text">

Finally the name attribute is usually used for associating two or more elements with each other, like a <label> in the previous example.
Or for something like two checkboxes:

<input type="checkbox" name="2">
<input type="checkbox" name="1">

Thank you so much! :heart:

1 Like