Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset all default styles of the HTML5 button element

Tags:

Scenario

I use the <button> element which appeares just as plain text with an "+" on right end.
On click a div element expands and reveals some information. I think the button element is semanticaley correct to represent such a ... button ... trigger.

Problem

So I have mixed some buttons and h2 elements and I have got a visual problem. After resetting all default user agent style's I expect that every element I introduce to the document looks plain and unstyled.

But the button element does not look that plain. It has an text, slightly, text indention.

Example

First, three elements are <h2><button>TEXT</button></h2> and the two from above are just <h2>TEXT</h2>

First, three elements are <h2><button>text node</button></h2> and the two from above are just <h2>text node</h2>

CSS

* {         /*Reset's every elements apperance*/         background: none repeat scroll 0 0 transparent;         border: medium none;         border-spacing: 0;         color: #26589F;         font-family: 'PT Sans Narrow',sans-serif;         font-size: 16px;         font-weight: normal;         line-height: 1.42rem;         list-style: none outside none;         margin: 0;         padding: 0;         text-align: left;         text-decoration: none;         text-indent: 0; } 

Other element's CSS

The other elements use background-image, text-transform:uppercase and that's it. In Firebug there are no paddings,margins,text-indents or other "soft" or "hard" properties which could mess things up. I played around with display settings but it does not "fix" anything or make it worse.

Question

Can anybody explain why, even after resetting the default styles, there is this visual failure on the <button> element?

like image 385
Tomkay Avatar asked Apr 18 '13 07:04

Tomkay


People also ask

How do I change the style of a button in HTML?

Use a semi-colon to separate the different style elements in the HTML button tag. Type color: in the quotation marks after "style=". This element is used to change the text color in the button. You can place style elements in any order in the quotation markers after "style=".

How do I reset CSS to default settings?

Answer: Use the CSS all Property You can simply use the CSS all property with the value revert to remove the additional author-defined CSS styling for an element (i.e. reset to browser's default CSS styling).

How do I create a reset button in HTML?

The <input type="reset"> defines a reset button which resets all form values to its initial values. Tip: Avoid reset buttons in your forms!

How do I remove a style from a specific element?

Use the style. removeProperty() method to remove CSS style properties from an element, e.g. box. style. removeProperty('background-color') .


1 Answers

button::-moz-focus-inner, input::-moz-focus-inner {   border: 0;   padding: 0; } 

add this one also in css it will solve your problem.

like image 59
Manish Sharma Avatar answered Nov 07 '22 04:11

Manish Sharma