Note:
answer will be like this .. yes ..there are rule and approach.. it's depend on adoption agency algorithm etc. you can follow those (links) etc. and your short description . i am not looking for any algorithm or more..
from example if an a
tag nest an a
tag. chrome browser restructure html . similar for a button
tag . both are invalid html structure
I know a
and button
tag are both interactive element. interactive elements(a,button,input etc) are related to the user's activity.
From the comment:
it’s too broad question.
- Only answer for below example code or scenario.
I think every browser should work same way from somewhere one point... That means should follow some basic rules or approach. If anyone found something like this please mention.
why I am looking for this ?
when I work for a client . I find many invalid html structure . many types of html structure. sometime I need to redesign for invalid html structure. I think I need to understand the concept of browser restructure for further web development..
follow those question Q1 and Q2
let aTag = document.querySelectorAll('a')
let buttonTag = document.querySelectorAll('button')
console.log('===a tag===')
aTag.forEach(function(item){
console.log(item)
})
console.log('===button tag===')
buttonTag.forEach(function(item){
console.log(item)
})
.card{
display: flex;
flex-direction: column;
padding: 10px;
border: 1px solid slateblue;
width: 200px;
text-align: center;
}
<a href="" class="parent a-tag">
<div class="card">
<h4>Title</h4>
<p>Paragraph</p>
<button>Add to Cart</button>
<a href="" class="child a-tag">Compare Product</a>
</div>
</a>
<button>
<a href="">A Tag</a>
<button>Button</button>
</button>
Picture from console google chrome browser
`; not as part of a general rule, it's just in the spec that that's the agreed way to handle that particular mistake. – IMSoP Nov 13 '20 at 14:16