cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              <h1>Styling Forms</h1>
<h2>If <code>[type=textish]</code>, <code>[type=buttonish]</code>, &amp; <code>[type=togglable]</code> Existed in CSS</h2>


HTML has a lot of great input types, but it's hard to style all of them the way you want without accidentally styling other things. The dozen input types, checkboxes, radio buttons, select boxes, textareas - all of these elements really only fall three 'categories' of input that we can grab and style accordingly:

- textish
- buttonish
- togglable

So why can't we style all things that look like <input type=text> with something like: input[type=textish]?

This is my experiment to see if there are more effective ways of selecting input elements to style them.

I created a list of selectors we want to target in JavaScript, and then used EQCSS to allow us to use that variable name in our CSS and insert the entire list of selectors. This also allows us to write functions that alter how that list of selectors is returned to us, so we can easily add :hover, :focus, :active and other modifications to our selectors fairly easily.


<!-- Text-like -->
<input type=hidden placeholder=hidden>
<input type=text placeholder=text>
<input type=search placeholder=search>
<input type=tel placeholder=tel>
<input type=url placeholder=url>
<input type=email placeholder=email>
<input type=password placeholder=password>
<input type=date placeholder=date>
<input type=month placeholder=month>
<input type=week placeholder=week>
<input type=time placeholder=time>
<input type=datetime-local placeholder=datetime-local>
<input type=number placeholder=number>
<input type=range placeholder=range>
<input type=color placeholder=color>

<!-- Toggle-like -->
<input type=checkbox value=checkbox>
<input type=checkbox value=checkbox>
<input type=checkbox value=checkbox>
<input type=radio name=radio value=radio>
<input type=radio name=radio value=radio>
<input type=radio name=radio value=radio>

<!-- Button-like-->
<input type=file value=file>
<input type=submit value=submit>
<input type=reset value=reset>
<input type=button value=button>
<button>real button</button>
              @element input, textarea, select, button {

  /* set width for most inputs */
  select {
    display: block;
    width: 100%;

  /* Give default style to text inputs and buttons */
  select {
    -webkit-appearance: none;
    appearance: none;
    padding: .5em;
    min-height: 2em;
    margin: .5em 0;
    color: #555;
    background-color: white;
    border: 1px solid rgba(0,0,0,.3);
    border-radius: 0;
    line-height: 1;
    font-size: 12pt;
    font-weight: 400;
    font-family: 'Source Sans', sans-serif;

  /* Set border radius on buttons and select */
  select {
    min-height: 0;
    border-radius: 3px;
    cursor: pointer;

  /* enhance button styles */
  eval('buttonish') {
    background-color: transparent;

  /* size togglable inputs */
  eval('togglable') {
    min-height: 1em;
    display: inline-block;
    cursor: pointer;
  [type=radio] {
    border-radius: 100%;
  eval('action("checked",togglable)') {
    background-color: #999;
    box-shadow: inset white 0 1px 0,
                inset white 1px 0 0,
                inset white -1px 0 0,
                inset white 0 -1px 0;
  /* add min-height to textarea */
  textarea {
    min-height: 5em;

  /* enhance select */
  select {
    padding-right: 1.5em;
    text-indent: 0.01px;
    text-overflow: '';
    background-repeat: no-repeat;
    background-position: calc(100% - .5em) 50%;
    background-size: 12px;
    background-image: url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E %3Cpolygon opacity='0.6' points='0,4 16,4 8,12'/%3E %3C/svg%3E ");
  select::-ms-expand {
    display: none;

  /* input & select hover styles */
  select:hover {
    border: 1px solid gold;

  /* input & select focus styles */
  select:focus {
    background-color: lightyellow;

  /* button hover styles */
  eval("action('hover',buttonish)") {
    color: white;
    background-color: #999;

  /* button focus styles */
  eval("action('active',buttonish)") {
    color: white;
    background-color: #555;

  /* fix type=search padding */
  [type=search] {
    padding-right: 0;
              /* selector lists */
var textish = [
  '[type=text]', '[type=search]', '[type=tel]', '[type=url]', '[type=email]', '[type=password]', '[type=date]', '[type=month]', '[type=week]', '[type=time]', '[type=datetime-local]', '[type=number]', '[type=color]', 'textarea'
var togglable = [
  '[type=checkbox]', '[type=radio]'
var buttonish = [
  '[type=submit]', '[type=reset]', '[type=button]', 'button'

/* return selectors with :states using action('state',arrayName) */
function action(state,array){
  var selectors ='';
    selectors += array[i]+':'+state
    if (i<array.length-1) {
      selectors += ', '
  return selectors

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................