Explain Codes LogoExplain Codes Logo

Html Entity for Check Mark

html
responsive-design
css
javascript
Anton ShumikhinbyAnton Shumikhin·Dec 25, 2024
TLDR

To display a simple or bold check mark in HTML, use the entities ✓ (✓) or ✔ (✔) respectively. Plug them right inside your HTML code to represent these symbols.

Example:

<p>Check mark: &#10003; (✓) <!-- This check mark enjoys simple lines and minimalist design --></p> <p>Bold check mark: &#10004; (✔) <!-- Bold, firm and unapologetically square --></p>

Alternatives: The art of the image

While HTML entities are your go-to for simplicity, there are moments when they aren't the perfect fit. For instances where compatibility is at stake with older browsers, you might consider using an image as your check mark. Here, we guarantee the symbol rendition is consistent:

<img src="checkmark.png" alt="Check mark"> <!-- An image is worth a thousand code lines, huh? -->

Ensure you have permissions for the image, and an alt attribute is a must (screen readers love them).

Hex and Decimal Notations

Each HTML entity check mark comes with both a hexadecimal (hex) and decimal notation.

  • Hexadecimal: &#x2713; (✓) or &#x2714; (✔)
  • Decimal: &#10003; (✓) or &#10004; (✔)

Hex might be considered a tad more readable as it matches the Unicode standard, but both play nice with HTML. Choose whatever suits your style.

Fallbacks: Dealing with older browsers

When dealing with legacy browsers, compatibility is not just a key, it's the whole damn locksmith. Always take the time to test your pages across different environments. If your symbol doesn't render as expected, consider images or even CSS as a fallback to render the check mark:

.check::before { content: "✔"; // CSS magic happens here 🧙‍♀️. }

This little piece of code cleverly injects the check mark symbol before any element with the check class. Magic!

Unicode: The character master

To ensure your check marks and other characters are showing up right, always save your HTML as Unicode (UTF-8 or UTF-16). This helps prevent those "Monday morning" characters.

Moreover, resources like AmpWhat or Wikipedia's list are great for discovering new character possibilities for not just check marks but for all characters.

Styling: Dress up your check mark

Being able to customize is the icing on the cake. Use CSS for styling HTML entities, giving your check marks a wardrobe:

.custom-check { color: green; // Because who doesn't love green? font-size: 2em; // Size does matter here. }

Dynamic Insertion: JavaScript to the rescue

Perhaps you prefer a more dynamic method? With JavaScript, you can add check marks into the DOM:

document.getElementById('check-container').innerHTML = '&#10004;'; // JavaScript ninjutsu! 🥷

Here's an interactive, on-the-fly method when an HTML entity isn't enough.