Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • CSS Tutorial
  • CSS Exercises
  • CSS Interview Questions
  • CSS Selectors
  • CSS Properties
  • CSS Functions
  • CSS Examples
  • CSS Cheat Sheet
  • CSS Templates
  • CSS Frameworks
  • Bootstrap
  • Tailwind
  • CSS Formatter
Open In App
Next Article:
How To Set Alternate Table Row Color Using CSS?
Next article icon

How to Align Right in a Table Cell using CSS ?

Last Updated : 16 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Aligning right in a table cell means positioning the content of the cell to the right side. In CSS, this can be achieved by applying the text-align property to the table cell or using the td selector.

Align right in a table cell Using text-align property

To align the contents of a table cell to right, we can use the text-align property in CSS. we Apply text-align: right; to the <td> element or its parent <table>. The cells which will be the table data can be styled using the text-align property to right and that will result in the desired solution. 

Syntax

text-align: property_value;

Example: In this table, the text-align: right; property is applied to <td> elements, ensuring that all data inside the table cells (such as prices and durations) is aligned to the right.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <title>Table Example</title>     <style>         table,         td,         th {             border: 1px solid;             padding: 20px;         }          td {             text-align: right;         }     </style> </head>  <body>     <table>         <tr>             <th>Course Name</th>             <th>Price</th>             <th>Duration</th>             <th>Mentor</th>         </tr>         <tr>             <td>DSA Basics</td>             <td>300</td>             <td>12 hours</td>             <td>John</td>         </tr>         <tr>             <td>Operating System Fundamentals</td>             <td>500</td>             <td>15 hours</td>             <td>Smith</td>         </tr>         <tr>             <td>Advanced DSA</td>             <td>1000</td>             <td>25 hours</td>             <td>Chris</td>         </tr>         <tr>             <td>Networking Fundamentals</td>             <td>500</td>             <td>10 hours</td>             <td>James</td>         </tr>         <tr>             <td>Android Development</td>             <td>2000</td>             <td>30 hours</td>             <td>Kevin & Pat</td>         </tr>     </table> </body>  </html> 

Output:

Using-text-align-property
Align right in a table cell Using text-align property Example output



Next Article
How To Set Alternate Table Row Color Using CSS?

M

meetgor
Improve
Article Tags :
  • Web Technologies
  • CSS
  • CSS-Properties
  • CSS-Questions

Similar Reads

  • How To Set Alternate Table Row Color Using CSS?
    To set alternate table row colors, we can use the :nth-child() pseudo-class in CSS. This technique helps improve the readability of a table by making it easier to differentiate between rows. In this article, we'll cover how to set alternate row colors using the :nth-child() pseudo-class and provide
    3 min read
  • How to create table cell using HTML5 ?
    In this article, we will create cell in a table by using a combination of <tr> and <td> tag in a HTML table. Syntax: <table> <tr> <td> . . . </td> <td> . . . </td> </tr> </table> Example: <!DOCTYPE html> <html> <head> <
    1 min read
  • How to make a Animated Table using HTML and CSS ?
    Table is an arrangement of data in rows and columns, or possibly in a more complex structure. Tables are widely used in communication, research, and data analysis. In this article, we are going to create a Table with animation over its columns. We are going to implement it using HTML and CSS. Approa
    3 min read
  • How to use text-align property inside a table in CSS ?
    Text align is a CSS (Cascading Style Sheets) property that is used to specify the horizontal alignment of text within an HTML element. It is commonly used to align text within a block-level element such as a paragraph, heading, or table cell. The "text-align" property accepts several values. left: I
    5 min read
  • How to Center an Image using text-align Property in CSS ?
    Aligning an image horizontally within a container can sometimes be challenging. In this article, we will explore how to center an image using the text-align property in CSS. Understanding the text-align PropertyThe text-align property in CSS is used to specify the horizontal alignment of text within
    2 min read
  • How to define a table caption using HTML ?
    In this article, we define a table caption by using the <caption> tag element. The caption element is used to specify the caption of a table. This tag will be inserted just after the table tag. Only one caption can be specified for one table. It is by default aligned to the center. Syntax:
    1 min read
  • How to prevent text in a table cell from wrapping using CSS?
    Preventing text from wrapping in a table cell ensures the content stays on one line, maintaining the layout's integrity. Using the CSS property white-space: nowrap;, you can control text behavior, avoiding unwanted line breaks within table cells. Syntax: white-space: normal|nowrap|pre|pre-wrap|pre-l
    2 min read
  • How to arrange text in multi columns using CSS3 ?
    In many websites, content is often displayed in parallel stacks to present more information in a compact space, similar to how newspapers and books are formatted. This pattern helps display large amounts of content in a small area, making it easier to read. In this article, we will learn how to arra
    4 min read
  • How to create Right Aligned Menu Links using HTML and CSS ?
    The right-aligned menu links are used on many websites. Like hotels website that contains lots of options in the menu section but in case of emergency to make contact with them need specific attention. In that case, you can put all the menu options on the left side of the navigation bar and display
    3 min read
  • How to Align Images Side By Side using CSS ?
    Images side by side means placing multiple images in a single row next to each other. This arrangement shows images in a horizontal line, making it great for photo galleries, and comparing pictures. To align images side by side using CSS, we can use flexbox or grid for layout. Table of Content Using
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences