Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a <div> or <a href="#"> to align center

Tags:

center

I'm using the following code in body section.

<center><a href="contact.html" class="button large hpbottom">Get Started</a></center>

Is there any alternative for <center> tag?

How can I make it center without using <center> tag?

like image 844
Gilchrist Adam Avatar asked Oct 25 '13 12:10

Gilchrist Adam


People also ask

How do I make a div a hyperlink?

You can't make the div a link itself, but you can make an <a> tag act as a block , the same behaviour a <div> has. You can then set the width and height on it. However, this doesn't make a 'div' into a link. It makes a link into a block element.

Can we use href on div?

If you absolutely need to use JavaScript, one way is to find a link inside the div and go to its href when the div is clicked. This is with jQuery: $(". myBox").

How do you create a div in HTML?

The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute. Any sort of content can be put inside the <div> tag!

Can div be clickable?

The answer is definitely yes, but you will need to write javascript code for it. We can use a click handler on the div element to make it clickable.


2 Answers

Add text-align:center;display:block; to the css class. Better than setting a style on the controls themselves. If you want to change it you do so in one place.

like image 110
Fred Avatar answered Sep 28 '22 03:09

Fred


You can do this:

<div style="text-align: center">
    <a href="contact.html" class="button large hpbottom">Get Started</a>
</div>
like image 29
Misha Zaslavsky Avatar answered Sep 28 '22 02:09

Misha Zaslavsky