Stephon Ripton1,890 Points
Why can't we do this? document.querySelector('MyTitle');
instead we have to do it like this: ('[title=MyTitle]')?
Nicholas Grenwalt46,624 Points
If you just inserted 'MyTitle' into querySelector it would be looking for a regular dom element with the name of 'MyTitle' specifically. When you use the bracket syntax you are searching for attributes that match a particular value on an attribute. In this case, they are looking for the first occurrence of an element where it's title attribute is set to MyTitle. It has nothing to do with what the actual text happens to say inside the element, but rather it is just for targeting purposes for styling, manipulation, etc..