Hung-Yi's LogoHung-Yi’s Journal

Pure CSS Map Marker

Learn how to make a map marker icon with just HTML and CSS, no icon fonts or images required. You can even customize the colors in the CSS to whatever you want.

A cute little map marker happens to be one of the things you can easily create with pure CSS without too much sorcery. All it takes is a div with 3 rounded corners, some transform rotation, and (optionally) a matching pair of :before and :after CSS pseudo-elements to dress it up.

Check it out!

To get the above result, include the following CSS somewhere on the page (or in an appropriate place in your project).

.marker {
    /* Set the marker size here */
    width: 2rem;
    height: 2rem;
    border-radius: 2rem;
    /* Set the marker color here */
    background: #aa3300;

    display: inline-block;
    border-bottom-right-radius: 0;
    position: relative;
    transform: rotate(45deg);

    /* optional fanciness */
    border: 1px solid #881100;
}
/* inner circle (optional if you don't need the central dot) */
.marker::before {
    content: "";
    background: white;
    width: 50%;
    height: 50%;
    border-radius: 100%;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    /* optional fanciness */
    box-shadow: 0.1rem 0.1rem 0.2rem 0.1rem rgba(0, 0, 0, 0.1);
}
/* shadow (optional if you don't need a shadow) */
.marker::after {
    content: "";
    background: rgba(128, 128, 128, 0.2);
    width: 75%;
    height: 75%;
    border-radius: 100%;
    position: absolute;
    top: 100%;
    left: 100%;
    transform: translate(-50%, -50%) rotate(45deg) scaleX(0.5);
}

Then place this HTML where you want the marker to appear.

<div class="marker"></div>