Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying an <a> anchor inline

Tags:

html

css

What CSS makes <a> tags show on a single line, rather than under each other? Maybe have a link in <li> tag?

like image 561
Seb Avatar asked Sep 02 '13 18:09

Seb


People also ask

How to display an anchor in HTML?

Anchor or the HTML <a> element is displayed as inline by default. So that if we have link within our paragraph/text, it will seamlessly blend in. For navigation menu purpose, which consists of links (wrapped in div or ul li or other) we can make the anchors displayed as block elements.

What is an anchor element tag?

The anchor element tag is the letter “a” surrounded by angle brackets like this: <a>. Both the opening and closing attributes are required, and all of the content between the tags makes up the anchor source.

Is it possible to override the display property for anchor elements?

Remember, only override the display property for anchor element which is placed inside a parent container, not for all anchor element. Find...

How do I reference an anchor in typora?

This allows you to then reference that anchor with [text] (#my-anchor-name). This functionally works in Typora as it is standard MD, but the issue I have is in how the anchor is displayed. Currently it is recognized as just plain inline html, and unlike <br/> or <p> tags, will always be shown in the displayed text.


3 Answers

I believe you want:

a {
    display: block;
}

edit

Anchors by default show inline, but the related CSS is:

a {
    display: inline;
}

You could also use inline-block which gives you a bit more functionality (although some older browsers support it poorly).

like image 191
DACrosby Avatar answered Nov 04 '22 01:11

DACrosby


I created an example for you which answers your second question.

<p id="top">This is the top of the file</p>

<ul> Favourite sports
<li><a href="http://en.wikipedia.org/wiki/Football">Football</a></li>
<li><a href="http://en.wikipedia.org/wiki/Tennis">Tennis</a></li>
<li><a href="http://en.wikipedia.org/wiki/Rugby_football">Rugby</a></li>
</ul>



<p><a href="#top">This link goes to the top</a></p>

The tag li refers to list item. Links are written the same way in ordered and unordered lists.

like image 38
pablofiumara Avatar answered Nov 04 '22 00:11

pablofiumara


If you want a link in a <li> tag:

<ul>

<li> 
<a href="#">Link here.</a> 
</li>

</ul>

CSS:

li {
display:inline-block;
}

Example here

like image 33
Josh Crozier Avatar answered Nov 04 '22 00:11

Josh Crozier