Resources
Work with HTML Output
This uses the basic @variableName
syntax. This will result in encoding html, so tags in that variable will be shown as html-source.
⬇️ Result | Source ➡️
- this is text, it doesn't have tags
- this string <em>has</em> html <strong>tags</strong>
⬇️ Result | Source ➡️
- this is text, it doesn't have tags
- this string has html tags
Sometimes you need to conditionally add tags, in which case Razor cannot verify that open/close of tags is correct. This would normally throw an error. so you need @:
.
⬇️ Result | Source ➡️
This is randomly bold or not, depending on a random event. If it's bold, you'll see a
strong
tag around it, otherwise not.