Create an HTML <table> Element Online

The HTML Table Generator creates table markup from the rows, columns, header, border, width, and alignment settings you select. The preview, HTML output, and C# output update together, so you can inspect the result before copying it into a webpage or .NET project.



Create an HTML <table> Element in C#

The HTML Code panel above contains the table markup produced from the current options. The C# Code panel below shows the equivalent programmatic workflow with Aspose.HTML for .NET .

The generated code follows this workflow:

  1. Create an HTMLDocument and a <table> element with Document.CreateElement() .
  2. Apply the selected border, width, and alignment settings through ICSSStyleDeclaration.SetProperty() .
  3. Add the optional header row, body rows, and cells with HTMLTableSectionElement.InsertRow() and the corresponding row operations.
  4. Append the table to the document body and save table.html with HTMLDocument.Save() .

Configure the table first, then copy the updated code into your .NET project.


HTML Table Generator FAQ

1. Should I set the table width in percent or pixels?

Use percent when the table should adapt to the width of its parent container. Use pixels when you need a fixed table width that does not change with the surrounding layout.

2. Why does changing the table alignment sometimes have no visible effect?

Left, center, and right alignment use the free horizontal space around the table. If the table width fills its container, there is no remaining space in which to move it. Reduce the width to make the selected alignment visible.

3. Why is the table border not visible in the preview?

The border is not visible when its width is 0 or its style is none or hidden. Select a visible style such as solid, dashed, or dotted and set a border width greater than zero.

4. How large a table can I create with the generator?

You can generate from 1 to 100 body rows and from 1 to 100 columns. If Header row is enabled, the generator adds a separate header above the selected number of body rows.

5. Can I add the generated table to an existing HTML document?

Yes. Replace the parameterless HTMLDocument constructor with new HTMLDocument("input.html"), then append the generated table to the document body or another selected element and save the modified document to a new file.


Get Started with Aspose.HTML for .NET API

Install Aspose.HTML for .NET from NuGet with the .NET CLI:

dotnet add package Aspose.HTML

You can also use the NuGet Package Manager UI or run Install-Package Aspose.HTML in the Package Manager Console. See the installation guide for setup details, or request a temporary license to evaluate the API without evaluation limitations.