how can i make an indent for hyperlink ? I've tried as this code but no success.
a { text-decoration: none; text-indent: 20px; }
<a href="#h"> html </a>
text-indent is not avalaible for inline elements
a { text-decoration: none; text-indent: 20px;/* not avalaible for inline elements */ display: inline-block; }
<a href="#h"> html </a>
padding could help
a { text-decoration: none; text-indent: 20px;/* not avalaible for inline elements */ padding-left:20px;; }
<a href="#h"> html </a>
Put this into a CSS file and link it to your HTML file using the link tag:
a {
text-decoration:none;
text-indent:20px;
}
My strong suggestion is go with the CSS file, it's a lot cleaner and allows you to target more elements, not just that specific anchor tag
text-indent
is for block or inline-block elements. So you can assign display: inline-block;
or display: block;
to the a
tag and get the desired effect. Here's a demo http://codepen.io/anon/pen/WRvOQd
If you don't want all hyperlinks to be indented, you could wrap it around a <div>
with a unique id; this is an alternate solution.
HTML:
<div id="indented">
<a href="#h"> html </a>
</div>
CSS:
a{
text-decoration:none;
}
#indented {
text-indent:20px;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.