Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is HTML's <a></a> tag default display type?

Tags:

html

css

I haven't been able to find anything that says what the default display is equivalent to in CSS's display properties. I ask, because whenever I attempt to add padding or margin to an <a> tag, it doesn't add it, I have to add the display property of inline-block for it to.

I don't know if this is browser specific or not, but would the default display of it be inline versus say inline-block (I obviously know it's not inline-block.

like image 897
Dylan Cross Avatar asked Nov 25 '12 04:11

Dylan Cross


People also ask

What is the default display type of an A tag?

It is always display: inline by default.

What is HTML default display?

Every HTML element has a default display value depending on what type of element it is. The default display value for most elements is block or inline . This panel contains a <div> element, which is hidden by default ( display: none ).

What is the default for display CSS?

inline. Inline is the default display value for every element in CSS. All the HTML tags are displayed inline out of the box except some elements like div , p and section , which are set as block by the user agent (the browser).


1 Answers

It is always display: inline by default. Horizontal margins, and padding on all sides should work without having to change its display property.

This remains true even in HTML5. If you are applying styles to an <a> element that contains flow elements or any other elements that are represented in CSS as display: block, you should set the <a> itself to a proper block container type such as block or inline-block for its layout to work as intended.

like image 120
BoltClock Avatar answered Sep 21 '22 13:09

BoltClock