Changing Appearance Of Element With CSS

I've recently just found this interesting CSS property that allows you to style any element you want as a browser default element.

Each browser has there own default styling for the standard HTML elements you can find on a page, for example a button in Chrome will look different than a button in Firefox.

With this CSS property you apply this to any HTML element and it will look like the default element in that browser. You can now style that anchor tag link to look exactly like that button, or make a paragraph look like a textbox.

All you have to do is use the CSS property -appearance.

This is currently only supported in webkit and firefox browsers so you need to prefix the property with the browser prefixes.







Then you can use these CSS classes in the HTML.

<p class="lookLikeAButton">This is a paragraph</p>
<p class="lookLikeAListbox">This is a paragraph</p>
<p class="lookLikeAListitem">This is a paragraph</p>
<p class="lookLikeASearchfield">This is a paragraph</p>
<p class="lookLikeATextarea">This is a paragraph</p>
<p class="lookLikeAMenulist">This is a paragraph</p>

There different elements you can change the appearance to can be found here. http://css-infos.net/property/-webkit-appearance

In the demo I change paragraphs to these different elements.


Back to top

Learn how to code with Treehouse

  • Learn projects with access to 1000+ videos
  • Practice live with our Code Challenge Engine
  • Get help in our members-only forums

Start with a 7 day free trial