Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Responding to User Interaction The Event Object

Why does he write LI instead of li?

can you explain me why he typed LI in stead of li?

1 Answer

Hi there,

The tagName method returns the name of the tag in capital letters when used on an HTML DOM. For an XML DOM tree it returns the tag name as typed. Documentation


Do you know why?

No idea - sorry! :smile:

so i just have to always type that in caps lock?

Yep - you need to compare it to the uppercase version of the HTML tag, without the angle brackets. So <li> is returned by tagName as a string of "LI", a <div> is returned as "DIV" etc.

but can i write in lower case if i do == instead of === ?

Not sure - try it and see if it works!

ehh, dont have time

It doesn't matter. I tried using strictly equals (===) with lower case 'li'. Still doesn't work. The returned tag name is always in the canonical uppercase form.