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 (Retiring) Making Changes to the DOM Styling Elements

tal Shnitzer
PLUS
tal Shnitzer
Courses Plus Student 5,242 Points

what is style property 'block'?

it is used in this Video, but no explanation of what it is?

3 Answers

Lee Vaughn
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Lee Vaughn
Treehouse Teacher

Styles are CSS settings. Block is a setting for the display property that determines how elements are displayed on the page. Most elements have a default display property of either block or inline.

Click the link at the bottom to learn more about the display property but the TLDR version is that block level elements always start on a new line and stretch as far as possible to the right and left. Inline elements do not start on a new line and only take up as much wide as necessary.

https://www.w3schools.com/css/css_display_visibility.asp

tal Shnitzer
tal Shnitzer
Courses Plus Student 5,242 Points

Thanks, it doesn't make sense though in the context of this Video where the display property was set to 'block' in order to restore the previous setting 'none' and let the element it re-apear . I don't know what TLDR is Sorry

Lee Vaughn
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Lee Vaughn
Treehouse Teacher

Sorry, TLDR is internet slang for a short explanation. It stands for "Too Long, Didn't Read".

Can you clarify what part doesn't make sense and I can try to help?

tal Shnitzer
PLUS
tal Shnitzer
Courses Plus Student 5,242 Points

here is the code that contains the 'block' setting of the display property (line 4): toggleList.addEventListener('click', ()=> { if (listDiv.style.display == 'none') { toggleList.textContent = 'Hide list'; listDiv.style.display= 'block'; } else { toggleList.textContent = 'Show list'; listDiv.style.display = 'none'; } });

this code makes the text appear/re-appear upon clicking the button. what's in 'block' property makes it reappear? and how could I have understood it from the above explanation, if I was looking for such a property myself?