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! While you're at it, check out some resources Treehouse students have shared here.

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 Making Changes to the DOM Create New DOM Elements

Travis Williams
Travis Williams
2,529 Points

Browser compatibility with Firefox?

I running firefox 137 on Debian 12, but I also tested this in Windows 11 with Firefox and got the same result.

When I enter const item = document.createElement('li') and then call item in the console it only returns the opening LI tag as <li> as an HTMLLIElement prototype.

Everything else has worked for me up to this point. Is there a way to work around this in Firefox as it's my preferred browser, and would be helpful to know to avoid writing code that isn't compatible with it for other users.

1 Answer

Steven Parker
Steven Parker
232,176 Points

HTML allows the ending tag (</li>) to be omitted. It sounds like the browser is just displaying this optional form.

Does this cause a problem?

Travis Williams
Travis Williams
2,529 Points

Thanks that's helpful to know. I couldn't find anything about that when I was looking for others with the same issue.

I initially thought it was causing a problem because when I tried to insert my li element and update the page I was seeing that HTMLLIElement get inserted instead, but as I finished the video I learned I was doing it wrong and didn't have any issues when I followed Guil's instructions.