Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make anchor tag fit to content? not entire width of page

Tags:

html

css

I have got the look I desire with my css. A centered <p> and <div> one on top of the other and they are both wrapped in <a> tags.

Now my issue is that the <a> tags go for the entire width of the page, I just want to be able to click on the link where the actual content is.

example link: https://jsfiddle.net/vinko_k_design/dge4fx2z/

like image 502
Vinko Avatar asked Jun 02 '15 03:06

Vinko


People also ask

How do I change the width of an anchor tag?

css: <style> li { width: 110px; height: 42px; background-color: black; } li a { width: 32px; height: 32px; color: white; } </style> html page: <li><a href="#">write something</a></li> you need to set anchor tag's display property as block :: 'display:block;' , then only it will accept values of height and width.

How do I make the content fit the screen in HTML?

You should set body and html to position:fixed; , and then set right: , left: , top: , and bottom: to 0; . That way, even if content overflows it will not extend past the limits of the viewport.

How do I make a div fit to content?

Answer: Use the CSS display Property You can simply use the CSS display property with the value inline-block to make a <div> not larger than its contents (i.e. only expand to as wide as its contents).


1 Answers

Put the anchor tags inside the p tag.

 <p class="page-nav"><a href="#map">Check out our Map</a></p>
like image 164
Steve Avatar answered Oct 05 '22 02:10

Steve