TWO CONTRASTING HTML CHALLENGE QUESTIONS
Every html element can have an attribute. Ans: True Which of these html tags cannot have an attribute? Ans: <!doctype html> I think these questions contradict each other. What do you think?
6/3/2020 11:05:41 AM
👑 Tchybooxuur!
80 Answers
New AnswerTo paraphrase: What are doctypes, elements, attributes, and tags (and how do they relate to each other with respect to these challenge Q's)? Here's what WHATWG has to say (w3c copies the standards from them): https://html.spec.whatwg.org/dev/introduction.html#a-quick-introduction-to-html Notably: 'HTML documents consist of a tree of elements and text. Each element is denoted in the source by a start tag, such as "<body>", and an end tag, such as "</body>".' (Tags are used to mark up a document so browsers can understand where nodes begin and end in a document.) 'Elements can have attributes [...]' (Hmm... 'can' not 'all'...) 'DOM trees contain several kinds of nodes, in particular a DocumentType node, Element nodes, Text nodes, Comment nodes, and in some cases ProcessingInstruction nodes.' (DocumentType nodes seem to be a separate category from Element nodes.) https://dom.spec.whatwg.org/#concept-element 'Element nodes are simply known as elements.' (...Just so we're using the same terminology.)
👑Tchybooxuur! <!DOCTYPE HTML> is not a tag. It is a "header" to give information to the browser on what type of document to expect to render. Yes, <br>, <img> etc. are tags, so they are allowed to have attributes. <!DOCTYPE HTML> isn't a tag to begin with.
When we say every, we generalise the elements in terms of most of them, not each of them. It is same as to saying, Generally, every element can have attributes, yet we know not all of them can have attributes... So, according to me, there is not much contradiction there
Alfred Juma See the meaning of "every" I got from Google. every /ˈɛvri/ determiner used before a singular noun to refer to all the individual members of a set without exception. "the hotel assures every guest of personal attention" Going by this definition, what you said might not be all that correct.
I think It can not have attributes. <!DOCTYPE> is not a tag, it is a declaration/information that allows the browser to know what kind of document it will except.. Although I think the question should not include the word "tags" It should be like: Which of these cannot have an attribute? "It is only what I think..."
👑Tchybooxuur! What I think is the first question asks about the html 4 (and not html 5 )elements and since we don't need <!doctyp html> tag in html 4 , thus the question excludes it .
Another similar point to note is that end tags cannot have an attribute, all attributes must be defined in the opening tags. Therefore, I don't also support the generalised opinion that all tags can have an attribute, but unfortunately that is how the question is☹
Explosive Creativity :D Yes, I understand. The question I'm asking is this: is <! doctype html> declaration also a html element? (Recall that not all the html elements require a closing tag). If yes, then the 2 questions are contrasting. Why can't it have an attribute?
Element mean a set of opening and closing tags with or without content inside (As far as I have known). Tag = <justTag> Element = <openingTag>Content</closingTag> And it is also a fact that: <!DOCTYPE HTML> does not have a closing tag </!DOCTYPE HTML> SO BASICALLY IT IS A TAG AND NOT AN ELEMENT. THE QUESTION IS ABOUT ATTRIBUTES OF ELEMENTS AND NOT THOSE OF TAGS 😄😄😄