+ 2

can someone please explain the for and id element in html to me ?

can someone please explain the for and id element to me ? i dont really understand them completely .. i understand their basic functions but i dont understand the relevance

20th Jan 2024, 9:09 AM
simon
4 odpowiedzi
+ 3
HTML for Attribute When used together with the <label> element, the for attribute specifies which form element a label is bound to. When used together with the <output> element, the for attribute specifies the relationship between the result of the calculation, and the elements used in the calculation. The HTML id attribute is used to specify a unique id for an HTML element. You cannot have more than one element with the same id in an HTML document.
20th Jan 2024, 10:14 AM
JaScript
JaScript - avatar
+ 2
We don't necessarily want to advertise for others here and/or write books.
21st Jan 2024, 12:55 PM
JaScript
JaScript - avatar
+ 1
simon , That text JaScript pasted is an uncredited copy of w3schools, which has (almost) all the HTML answers. Here're the links. You should bookmark the top of the site for future reference. https://www.w3schools.com/tags/att_for.asp https://www.w3schools.com/tags/att_id.asp
20th Jan 2024, 7:30 PM
Rain
Rain - avatar
0
For is an attribute mainly used for the html tag element <label> </label> the for-attribute use case that I see is connecting label to the html tag <input> the reason for its relevance is because the hit field for the input field become wider. Name: [ ] if you now how to use for and id properly with <label> and <input> you will notice that if you click on the Name: in other words the label it will also make it seem as if you press click into the input field as well but in regards for the Id attribute itself to target that specific element, you will always have to target said element id attribute name so when you start doing CSS to target that element with that id name it will be like this <html> <p id = "p1"> blah blah blah </p> </html> <style> #p1 { color: red; ///changes font color to red } </style> so you target said element with id with # without that is just: p to target all elements with p and if you want to target a specific group of P elements you will need to create a class, which is exactly like creating a id, for a p element but this identifier you can use for multple elemtents you wish to target at once anyways its refer to as the selector .p1 is class slelector #p1 id selector p is normal element selector there are attribute selectors as well this example of code targeting a submit button input[type='submit']:active { background-color: #0C1527; color: #FF9E03; border: 1px solid #FF9E03; border-radius: 10px; } im not sure how to target from elements specially with CSS yet exactly like im not sure the sytax to target that submit but if it had a id to it, idk if solo playground does not work all the way or something but i tried to use like a descendant selector which is like body p { color:purple; } so i first targeted the parent then the child p when i was learning, CSS it said <dv> are often use to target elments so maybe i could of put a div around it and target the div then the input element ...
22nd Jan 2024, 6:09 AM
Marcus Nieman Johnson
Marcus Nieman Johnson - avatar