Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Horizontally center text in a div?

Featured Replies

Hey,

 

I'm trying to center links horizontally in a div, I know this mustn't be too complicated...

 

This is the code:

 

<div id="HeaderRightCol">
<img src="imagesnew/greenpanel.gif" alt="" width="250" height="50" />

<div id="HeaderLink"><a class="HeaderLinks" href="<?php echo $currentPage ?>?ID=5&type=Home">FULL TIME COURSES</a><br /></div>

<div id="HeaderLink"><a class="HeaderLinks" href="<?php echo $currentPage ?>?ID=33">PART TIME COURSES</a><br /></div> 
<div id="HeaderLink"><a class="HeaderLinks" href="<?php echo $currentPage ?>?ID=34">IT COURSES</a><br /></div> 	
</div>

 

and this is the CSS:

 

#HeaderLink  {
width: 250px;
height: 46px;
border-bottom: 1px dotted #a1ae00;
}

 

I've tried 'text-align: center;' but this give vertical alignment. I could work around it with padding but is there a better way?

 

 

cheers :)

Why have you put your <a> links in <div>s? This really in unnecessary bloat of code. Strip them out - besides they all have the same ID, and you should only have one ID of the same name and tag per page.

 

Once you've stripped out the divs, use this CSS

 

#HeaderRightCol a {text-align:center;}

  • Author

Why have you put your <a> links in <div>s? This really in unnecessary bloat of code. Strip them out - besides they all have the same ID, and you should only have one ID of the same name and tag per page.

 

Once you've stripped out the divs, use this CSS

 

#HeaderRightCol a {text-align:center;}

 

Hey notbanksy, how do I space my links if theyre not in divs? I want them to look like the attached screen grab, I'll try that CSS too, cheers for that

post-15496-126960856786_thumb.png

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.