HTML Star Code

This page contains HTML code for adding a "star" symbol to a website or blog.

To display a star within a website's text, you need to use the relevant character entity reference. This is because the star is a special character. You can't just enter the star into the keyboard. Sure, you could copy and paste from another document but that's not a good idea (more on this below).

You can use characther entity references to create either a black star or white star. You can use either the entity number or its name.

HTML Entity Number

Here's how you use the HTML entity number to display a star on a webpage.

Source CodeResult
☆ ★

HTML Entity Name

Here's how you use the HTML entity name.

Source CodeResult
☆ ★ ★

Adding Styles

You can add styles to your star to make it stand out more. Styles can be added using Cascading Style Sheets (CSS).

In this example, we use the <span> tag to apply styles to various stars.

Source CodeResult

Warning About Copy/Paste

Note that it can be tempting to "copy and paste" a star from another source (for example a Word document or PDF) into your blog or website, but that's not normally a good idea. This could result in the star not appearing correctly for your users.

Therefore, you should always use one of the HTML entities on this page to ensure that the star appears correctly for your users.

About HTML Entities

HTML entities are used in HTML when you need to display a special character on a web page. These are often characters or symbols that can't easily be typed into a keyboard.

Check out this list of special characters for a comprehensive list of HTML entities.

About HTML.am

HTML.am was created in order to provide HTML tools, codes, tutorials, and other resources to help webmasters create and maintain their HTML documents.

HTML.am aims primarily at beginners, but may also be useful to web professionals.

About the HTML Codes

The HTML codes on this website are provided free of charge, for you to use however you wish. Feel free to modify the code to suit your own needs.

My Related Sites

Here are some of my other sites: