Create an HTML <mark> Element Online
The HTML Mark Tag Generator wraps plain text in a <mark> element. The
HTML Standard
defines this element for text highlighted because it is relevant in the current context, such as a search match or a passage referenced by nearby commentary.
The element adds meaning to the selected text; its appearance is controlled separately by browser defaults or CSS. Use a more specific semantic element when the intended meaning is emphasis or importance rather than contextual relevance.
HTML Mark Generator Options
- Text sets the plain-text content placed inside the generated
<mark>element.
Characters with special meaning in HTML are escaped before the preview and generated markup are updated. Entered tags remain visible text instead of becoming active HTML elements.
Create an HTML <mark> Element in C#
The C# panel shows how to create the configured <mark> element with
Aspose.HTML for .NET
. The generated code follows this workflow:
- Create an
HTMLDocument. - Create an
ElementnamedmarkwithCreateElement(). - Assign the entered text through
TextContent. - Add the element with
AppendChild()and writemark.htmlwithSave().
Enter the text first, then copy the updated C# code into your .NET project.
HTML <mark> Tag Generator FAQ
1. When should I use the HTML mark element?
Use <mark> for text that is relevant to the reader’s current task or to nearby commentary. Common cases include highlighting search matches and identifying the specific part of a quotation being discussed.
2. How does mark differ from em and strong?
The <mark> element identifies contextual relevance.
<em>
adds stress emphasis that can change a sentence’s meaning, while
<strong>
conveys importance, seriousness, or urgency.
3. Is marked text always displayed with a yellow background?
No. Browsers commonly apply a yellow background by default, but that appearance is not guaranteed and can be changed with CSS. The <mark> element should be selected for its meaning, not for a particular colour.
4. Should mark be used for syntax highlighting in source code?
Use <mark> only when a particular fragment is relevant to the current explanation, such as the line containing an error. For general syntax colouring by token type, use suitable elements and CSS classes rather than treating every coloured token as contextually relevant.
5. Is colour alone enough to communicate why text is marked?
No. Provide surrounding wording that explains why the passage matters, and choose foreground and background colours with sufficient contrast. The meaning should remain understandable when the highlight colour is not perceived.
Get Started with Aspose.HTML for .NET API
Install Aspose.HTML for .NET from NuGet with the .NET CLI:
dotnet add package Aspose.HTML
You can also use the NuGet Package Manager UI or run Install-Package Aspose.HTML in the Package Manager Console. See the
installation guide
for setup details, or request a
temporary license
to evaluate the API without evaluation limitations.
Other Supported HTML Generators
Create and preview markup for other common HTML elements.