html - Is it OK to style anchor tags as block elements? -
is ok use html below style anchor block element? read somewhere before it's wrong, can't see why , it's damn convenient! drawbacks of method, if any?
<style> a.button{ display:inline-block; padding: 10px 20px; border: 1px solid grey; } </style> <a class="button" href="#link">click me!</a>
not ok <a>
elements styled blocks or inline-blocks, it's necessary in cases, avoid problems.
take bit of code:
a {outline:1px dotted}
click <a href="#"><div>here</div></a>
in browsers, outline around anchor not proper rectangular shape, because of div inside. in others, outline isn't there @ all. if change a's display block
, differences go away; has nice rectangular outline in browsers.
a {outline:1px dotted; display:block}
click <a href="#"><div>here</div></a>
so, no need worry.
Comments
Post a Comment