what is the difference between element and attribute | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

what is the difference between element and attribute

6th Jun 2016, 9:10 AM
Krishna Rout
Krishna Rout - avatar
4 Answers
+ 2
Elements are made up of opening tags, closing tags, and content between them e.g. <p>this whole line is an element</p> Attributes, on the other hand can be seen as additional settings for elements e.g <p color="red">The opening tag has an attribute that changes this text to red</p > Attributes can be distinguished quite easily. They'll have a name e.g color or src. ..followed by an equals sign and a value enclosed in quotation marks.
12th Jun 2016, 11:02 PM
Stevie Gillen
Stevie Gillen - avatar
+ 1
<h1> is a tag. "<h1>Some Heading</h1>" is an html element. Some "lonely" tags are elements on their own. Like <br /> and <hr /> for example.
6th Jun 2016, 1:18 PM
ZinC
ZinC - avatar
+ 1
An attribute is something you assign to an element to make it behave a certain way.
21st Jun 2016, 10:31 AM
YouGoGayle
- 1
element like <h> attribute you add in the element <img src=_____> img is element src is attribute
6th Jun 2016, 9:54 AM
Abdala Bakheet
Abdala Bakheet - avatar