Recall & Review
beginner
What does the {@html} tag do in Svelte?
It allows you to insert raw HTML code directly into your component's output, rendering it as HTML instead of plain text.
Click to reveal answer
intermediate
Why should you be careful when using {@html} with user input?
Because it can lead to security risks like Cross-Site Scripting (XSS) if the HTML is not sanitized before rendering.
Click to reveal answer
beginner
How do you use {@html} to render a variable containing HTML in Svelte?
Use it inside curly braces like this: {@html variableName}, where variableName holds the HTML string.
Click to reveal answer
intermediate
Can {@html} render scripts or styles inside the HTML string?
Scripts inside {@html} are inserted but may not execute as expected. Styles will apply if valid. It's best to avoid scripts for security and behavior reasons.
Click to reveal answer
intermediate
What is a safer alternative to {@html} when displaying user content?
Sanitize the HTML string before using {@html} or use plain text rendering to avoid injecting unsafe HTML.
Click to reveal answer
What does {@html} do in Svelte?
✗ Incorrect
The {@html} tag renders the string as raw HTML inside the component.
Which risk is most associated with using {@html} on unsanitized user input?
✗ Incorrect
Unsanitized HTML can allow malicious scripts, causing XSS attacks.
How do you insert a variable named 'content' as HTML using {@html}?
✗ Incorrect
Use {@html content} to render the variable as HTML.
What happens if you put a <script> tag inside {@html} content?
✗ Incorrect
Scripts inside {@html} may not execute properly and pose security risks.
What is the best practice before using {@html} with dynamic content?
✗ Incorrect
Sanitizing content helps prevent security vulnerabilities.
Explain how {@html} works in Svelte and why you should be cautious when using it.
Think about how raw HTML can affect your page and security.
You got /4 concepts.
Describe a safe way to display user-generated HTML content in a Svelte app.
Focus on security and content safety.
You got /4 concepts.