Home >Web Front-end >CSS Tutorial >How Can I Style HTML Radio Buttons to Look Like Checkboxes on Print?

How Can I Style HTML Radio Buttons to Look Like Checkboxes on Print?

Barbara Streisand
Barbara StreisandOriginal
2024-12-11 02:46:09495browse

How Can I Style HTML Radio Buttons to Look Like Checkboxes on Print?

Styling HTML Radio Buttons as Checkboxes

Problem:
Users require printed forms to resemble official government documents, including radio buttons designed as square checkboxes. Despite the on-screen display of radio buttons, the printed version must reflect the checkbox style.

Solution:

Modern browsers like Firefox 1 , Chrome 1 , Safari 3 , and Opera 15 support the appearance property, which enables styling radio buttons to mimic checkboxes. Here's how to achieve this:

input[type="radio"] {
  appearance: checkbox;
}

This code applies the checkbox appearance to all radio buttons. The result in supported browsers will be:

<label><input type="radio" name="radio"> Checkbox 1</label>
<label><input type="radio" name="radio"> Checkbox 2</label>

Using the appearance property, it is possible to style radio buttons as checkboxes while avoiding the complexity of creating and synchronizing shadow checkboxes using JavaScript and CSS.

The above is the detailed content of How Can I Style HTML Radio Buttons to Look Like Checkboxes on Print?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn