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

HTML

Please, someone, help. This is very short line of code

""

Take a look at my answer. I supplied where i found the answer too (i dont pretend to know and remember everything lol :-)

https://teamtreehouse.com/workspaces/41639381#

5 Answers

Hi, You intentions are not clear. When I read your comments in the code I get the impression you want to stop the browser highlighting the text they are selecting by clicking and dragging across the page. Is this correct?

Yes

What outcome are you trying to achieve? Is it to stop a user copying the text, or just to visually not show the selection?

Thank you so much for trying to help, but I finally solved it.

<!DOCTYPE html>
<html>
<body>

<div style="background:red;"></div>
<script>
 let num = 200
 const div = document.querySelector('div')
div.style.width = div.style.height = `${num}px`
</script>

</body>
</html>
/*
Can someone  tell me why the div is square,
 I think it should be empty
 div because
 I only set the width, not the height.
*/

This second question, β€œCan someone tell me why the div is square, I think it should be empty div because I only set the width, not the height.” is straightforward.

div.style.width = div.style.height =${num}px``

You are setting the width to the height, which you are setting to your number in pixels. So yes, you are setting the width and the height.