• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 61
  • Last Modified:

html, css

In a td tag, I want to display the following at center like:

                        John Doe
                       First Player

The code below displays (left):

John Doe
First Player

       <td id="nameAlignment">
              <span id="name"">John Doe</span><br/>
              <span id="title">First Player</span>
        </td>

#name{
  font-size:2em;
  font-family:"Tahoma","sans-serif";
  font-weight:bold;
  color:rgb(89,89,89);
  white-space: nowrap;
}
#title{
  font-size:1.1em;
  font-family:"Tahoma","sans-serif";
  font-weight:bold;
  color:rgb(84,142,212);
  white-space: nowrap;
}
#nameAlignment{
  
}

Open in new window

0
Mike Eghtebas
Asked:
Mike Eghtebas
  • 5
  • 3
1 Solution
 
Kyle HamiltonData ScientistCommented:
#nameAlignment{
  text-align:center;
}
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Hi Kyle,

I had tried this code before but it only centers it at its box it adds to it not in the td tag.td
0
 
Kyle HamiltonData ScientistCommented:
see this fiddle:

http://jsfiddle.net/93ktcyfc/3/

If your text is not centered, then you must have something else going on which is not in the snippet you posted.

Please either post a link to the page, or adjust the fiddle to reflect your actual html.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
my bad, I needed to add colspan="3" elsewhere. This missing attribute was causing the problem.

Thanks,

Mike
0
 
Kyle HamiltonData ScientistCommented:
np :)
0
 
Kyle HamiltonData ScientistCommented:
Just some closing comments. With the caveat that I have no idea what it is you are actually working on :)

Avoid using ids for styling. IDs should only be used for unique elements that need to be accessed by scripts.
Styling should be done with classes.

Do not use tables for layout. This is a deprecated technique. Tables should only ever be used for actual tabular data.

I will not go into details here, but you can search the web for the reasons why, as well as best practices for developing modern websites.
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Hi Kyle,

I appreciate for the good comments you have made. I have made a resume in MS Word. Now, I am converting it to html. To tell the truth, it was a bit too complicated for me to go from table to div.

I will have few followup questions which I am preparing to post. I will send you a link, if it is okay with you, so I can benefit from your good comments.

Regards,

Mike
0
 
Kyle HamiltonData ScientistCommented:
sure. np
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now