0

I am looking to insert the align attribute for centering column data. I have several lines that are similar in composition to this:

tdHtml = tdHtml + "<td style=\"width:42px;\">" + PriorityFormat($(this).attr("ows_Priority_x0020_Number")); + "</td>";

Is this doable?

Thanks!

5
  • 4
    align is deprecated.. you should use text-align:center. Just add this style along with the width style. Commented Jul 17, 2013 at 20:34
  • Great, thanks for the response! I have almost zero experience with this, can you point me to where in the line I would need to add the text-align? I've tried a few things but no success so far. Thanks!
    – WCS
    Commented Jul 17, 2013 at 20:36
  • 1
    "<td style=\"width:42px;text-align:center \">" Commented Jul 17, 2013 at 20:37
  • 1
    Also you can use single quotes when they are encased in double quotes which saves the extra effort of escaping the double quotes.. "<td style='width:42px;text-align:center'>" Commented Jul 17, 2013 at 20:39
  • Brilliant! Thank you both, this worked exactly as needed.
    – WCS
    Commented Jul 17, 2013 at 20:41

2 Answers 2

1

Don't use inline css add class or target td by parent selector

Example:

tdHtml = tdHtml + "<td class='td-center'>" + PriorityFormat($(this).attr("ows_Priority_x0020_Number")); + "</td>";

CSS

.td-center {width:42px; text-align:center}
0

Vega and Sushanth have answered this question in the comments above. I used

"<td style=\"width:42px;text-align:center \">"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.