DEV Community

Cover image for HTML Tick Mark Code: Stylish and Interactive Checkbox Design
Prabhat Kumar
Prabhat Kumar

Posted on

HTML Tick Mark Code: Stylish and Interactive Checkbox Design

Creating visually appealing and functional web elements is a crucial aspect of modern web design. One of the most common interactive components found in forms and tasks lists is the HTML tick mark code. This article explores how to design a stylish and interactive checkbox that uses HTML tick mark and CSS to create a visually engaging user interface. By leveraging this design, developers can enhance user experience while maintaining simplicity.

Introduction to HTML Tick Mark Code

Checkboxes are essential components in forms, settings, and surveys, allowing users to select or deselect options. A well-designed checkbox doesn't just function; it also provides visual feedback, making the interaction feel smooth and responsive. The HTML tick mark code offers a simple yet powerful way to integrate checkboxes into your web projects, while adding a creative twist.

This guide will walk you through the process of styling a checkbox, including the use of HTML tick symbol, HTML tick character, and how to make the https://layakcoder.com/tick-mark/ come to life using CSS. We will start from the basic HTML structure and gradually enhance it with styling techniques that transform a plain checkbox into a dynamic interactive element.

Structuring the HTML for the Tick Mark

Before diving into the design, let’s take a look at the HTML tick mark structure. We begin with a basic HTML layout for a checkbox, which includes the input field for the checkbox and a label that will hold the tick mark:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Check Box || layakcoder</title>
</head>
<body>
    <input type="checkbox" id="_checkbox">
    <label for="_checkbox">
      <div id="tick_mark"></div>
    </label>



</body>
</html>
Enter fullscreen mode Exit fullscreen mode

In this structure:

  • The checkbox is hidden using display: none; in the CSS, making it invisible to users.
  • A label is used to create a clickable area that will act as the checkbox. The label element is linked to the checkbox by the for="_checkbox" attribute.
  • The div with the ID tick_mark serves as a container for the HTML tick mark, where the tick icon will be rendered when the checkbox is checked.

Designing the Tick Mark with CSS

Once the basic HTML is in place, we can move on to styling. The goal is to create an attractive checkbox that not only functions properly but also provides a visually satisfying experience for the user.

Setting the Background and Layout

The first step is to set the background color of the page to black and remove default margin and padding. This makes the checkbox stand out against the dark background. Here is how we style the body:

html,
body {
    height: 100%;
    background-color: black;
}

body {
    margin: 0;
}

Enter fullscreen mode Exit fullscreen mode

This ensures that the tick mark is visible and clearly stands out.

Styling the Label

The label will take the shape of a circular button. We use CSS properties like border-radius, box-shadow, and background-color to style it. Additionally, a smooth transition effect is applied to the label for a more interactive feel.

label {
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    width: 100px;
    height: 100px;
    margin: 0 auto;
    background-color: #5e2cd3;
    transform: translateY(-50%);
    border-radius: 50%;
    box-shadow: 0 7px 10px #bdb8ff;
    cursor: pointer;
    transition: 0.2s ease transform, 0.2s ease background-color,
      0.2s ease box-shadow;
    overflow: hidden;
    z-index: 1;
}

Enter fullscreen mode Exit fullscreen mode

This code positions the label centrally, making it round, and adds a shadow for depth. The transition effect enhances the user experience by animating changes like hover and click actions.

Adding the Tick Mark Using Pseudo-Elements

The most interesting part of this design is the HTML tick symbol, which appears when the checkbox is checked. We create the tick icon by using the :before and :after pseudo-elements. Initially, these elements are invisible with opacity: 0:

#tick_mark {
    position: absolute;
    top: -1px;
    right: 0;
    left: 0;
    width: 60px;
    height: 60px;
    margin: 0 auto;
    margin-left: 14px;
    transform: rotateZ(-40deg);
}

#tick_mark:before,
#tick_mark:after {
    content: "";
    position: absolute;
    background-color: #fff;
    border-radius: 2px;
    opacity: 0;
    transition: 0.2s ease transform, 0.2s ease opacity;
}

Enter fullscreen mode Exit fullscreen mode

These pseudo-elements create the two parts of the tick mark. The before pseudo-element forms the vertical line, and the after element forms the horizontal line of the tick.

Triggering the Tick Mark on Checkbox Selection

When the checkbox is selected, we use the :checked pseudo-class to change the background color and reveal the HTML tick character:

#_checkbox:checked + label {
    background-color: #07d410;
    box-shadow: 0 7px 10px #92ff97;
}

#_checkbox:checked + label #tick_mark:before,
#_checkbox:checked + label #tick_mark:after {
    transform: translate(0);
    opacity: 1;
}

Enter fullscreen mode Exit fullscreen mode

This code handles the HTML tick mark animation, where the tick mark appears and the label background turns green when the checkbox is checked.

Enhancing User Interaction with Hover and Active States

To further enhance the interactivity, we add a hover effect that shrinks the label and changes its shadow. This provides visual feedback when the user hovers over the checkbox, making the design feel more dynamic.

label:hover:before {
    width: 55px;
    height: 55px;
    box-shadow: inset 0 7px 10px #96a9ff;
}

label:active {
    transform: translateY(-50%) scale(0.9);
}

Enter fullscreen mode Exit fullscreen mode

The :active state reduces the size of the label, giving it a "pressed" look, which makes the user feel like they are interacting with a real button.

Conclusion
In this article, we walked through how to create a stylish and interactive HTML tick mark checkbox. By using HTML tick mark code and applying CSS for design and animations, we transformed a simple checkbox into an engaging user interface element.

With this HTML tick mark code, you can enhance any web form or to-do list by adding a custom checkbox design that improves the user experience. The smooth animations, visually appealing tick mark, and interactive states all contribute to making the checkbox more than just a simple form element – it becomes an engaging part of the interface.

By following these steps and incorporating the HTML tick mark symbol, HTML tick character, and HTML tick icon, developers can easily implement a visually appealing checkbox with functionality.

Top comments (2)

Collapse
 
ankur_sharma43234 profile image
Ankur Agrahari

Great article! The explanations were clear and the examples very practical. I especially appreciated the HTML Tick Mark Code: Stylish and Interactive Checkbox Design. A suggestion would be to dive a bit deeper into HTML Tick Mark Code . Overall, excellent work—looking forward to more insightful content!

Collapse
 
ashishkumar02 profile image
24x7service Centre

This article guides developers on creating stylish, interactive checkboxes using HTML and CSS. Learn how to integrate HTML tick marks and enhance user experience with dynamic, visually appealing form elements. Perfect for improving form design and functionality!