Unwanted space on the right of my Next.js component

I’m learning Next.js. I’m doing my portfolio. I have basics of HTML, CSS and I know JavaScript by coding on the back-end using Express.js.

In this code:

export const Work = () => {
    const listTest: WorkData[] = [
        {
            id: 1,
            company_name: 'Entreprise',
            profession: 'Front-end developper',
            content: "Developing a mobile application for a startupn - Front of multiple screens/components, integration of premium, integration of pictures galery, improving back-office",
            mission_nb: 9,
            hour_nb: 319,
            picture: '/assets/images/test.png',
            link: 'https://www.wikipedia.org/',
            technologies: ['flutter', 'javascript', 'postgresql', 'docker'],
            period: {
                start: new Date('2023-07-19'),
                end: null,
            },
        },
    ];


    return (
        <Section className="relative top-[50px]">
            <div className="grid grid-cols-1 gap-4">
                {listTest.map((work) => (
                    <WorkCard key={work.id} {...work} />
                ))}
            </div>
        </Section>
    );
};

const WorkCard: React.FC<WorkData> = ({ company_name, profession, content, mission_nb, hour_nb, picture, link, technologies }) => {
    return (
        <div className="bg-card border border-card rounded-xl shadow p-0 box-border">
            <div className="w-full pt-9 pb-5 pl-4 pr-0">
                <p className="text-md font-semibold whitespace-pre-line">
                    {content}</p>
                <p> missions: <span className="text-accent">{mission_nb}</span><br />
                    hours carried out: <span className="text-accent">{hour_nb}</span></p>
            </div>
        </div>
    );
}

I obtain involuntary right padding. How do I fix it? I don’t think I have any conflicts between styles as the code is still very simple, just using a div and giving CSS attributes by the className attribute so I don’t where this right padding comes from. How do I fix it please?

When i put p-0 in:

<div className="w-full p-0">
                <p className="text-md font-semibold whitespace-pre-line">
                    {content}</p>

It works and the content is side by side of the border. However, when I put p-1 or something like this, it adds too much space at the right side of the content.

If I put pl-2 (meaning I just add padding at left), it will add the padding at left. However, if I add too much space at the right for reasons I’m ignoring and even if I put pr-0, there is still right padding.

Image with p-0:

The behavior you are seeing is due to the fact that the width is calculated first, and then the text is wrapped when it would otherwise overflow.

To work around this, you could set text-align: justify via the text-justify class name. This reworks the spacing of the words such that the last word of the line is up to the very edge of the bounding box (like a newspaper text column).

const Section = ({ ...props }) => <section {...props} />;

const Work = () => {
  const listTest = [
    {
      id: 1,
      company_name: 'Entreprise',
      profession: 'Front-end developper',
      content:
        'Developing a mobile application for a startupn - Front of multiple screens/components, integration of premium, integration of pictures galery, improving back-office',
      mission_nb: 9,
      hour_nb: 319,
      picture: '/assets/images/test.png',
      link: 'https://www.wikipedia.org/',
      technologies: ['flutter', 'javascript', 'postgresql', 'docker'],
      period: {
        start: new Date('2023-07-19'),
        end: null,
      },
    },
  ];

  return (
    <Section className="relative top-[50px]">
      <div className="grid grid-cols-1 gap-4">
        {listTest.map((work) => (
          <WorkCard key={work.id} {...work} />
        ))}
      </div>
    </Section>
  );
};

const WorkCard = ({
  company_name,
  profession,
  content,
  mission_nb,
  hour_nb,
  picture,
  link,
  technologies,
}) => {
  return (
    <div className="bg-card border border-card rounded-xl shadow p-0 box-border">
      <div className="w-full pt-9 pb-5 px-2">
        <p className="text-md font-semibold whitespace-pre-line text-justify">
          {content}
        </p>
        <p>
          {' '}
          missions: <span className="text-accent">{mission_nb}</span>
          <br />
          hours carried out: <span className="text-accent">{hour_nb}</span>
        </p>
      </div>
    </div>
  );
};

ReactDOM.createRoot(document.getElementById('app')).render(<Work />);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.production.min.js" integrity="sha512-QVs8Lo43F9lSuBykadDb0oSXDL/BbZ588urWVCRwSIoewQv/Ewg1f84mK3U790bZ0FfhFa1YSQUmIhG+pIRKeg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.production.min.js" integrity="sha512-6a1107rTlA4gYpgHAqbwLAtxmWipBdJFcq8y5S/aTge3Bp+VAklABm2LO+Kg51vOWR9JMZq1Ovjl5tpluNpTeQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.tailwindcss.com/3.4.5"></script>

<div id="app"></div>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật