Html.Table

Accessing Data

Extracts data from HTML content into a table using CSS selectors to define columns.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Html.Table(html as any, columnNameSelectorPairs as list, optional options as nullable record) as table

Parameters

NameTypeRequiredDescription
htmlanyYesThe HTML content to parse. Can be a text value or binary (e.g., from Web.Contents or Web.BrowserContents).
columnNameSelectorPairslistYesA list of two-element lists, where each inner list is {columnName as text, cssSelector as text}. The CSS selector is evaluated for each row to extract the cell value.
optionsrecordNoAn optional record with options. Supports RowSelector (text) to define a CSS selector for determining rows.

Return Value

tableA table where each column is populated by evaluating the corresponding CSS selector against the HTML content.

Remarks

Html.Table extracts structured data from HTML content by evaluating CSS selectors, giving you precise control over which elements become rows and what each column contains. Unlike Web.Page, which automatically detects

elements, Html.Table can target any HTML structure — including
-based layouts,
    lists, card grids, or any other custom markup — as long as you can identify the elements with CSS selectors.

    How it works: The RowSelector option defines what constitutes a "row" in the HTML document. Power Query finds all elements matching the row selector, then for each row element evaluates each CSS selector in columnNameSelectorPairs relative to that row element to extract the cell value. The inner text of the matched element becomes the cell value by default.

    The columnNameSelectorPairs parameter: Each entry is a two-element list {columnName, cssSelector}. The column name is a text label for the output column; the CSS selector extracts the cell value from within each row element. If no element matches the selector for a given row, the cell value is null.

    CSS selector support: Standard CSS selector syntax is supported — element selectors (td, span), class selectors (.price), ID selectors (#total), attribute selectors ([data-id]), descendant combinators (div.card p.title), sibling combinators, and pseudo-classes like :nth-child() and :first-child.

    Attribute extraction: To extract an HTML attribute rather than the element's text content, use an attribute selector pattern: appending [attributeName] to the selector returns the attribute value instead of the inner text. For example, "a[href]" returns the href value of the matched anchor element.

    Authentication: Html.Table does not make HTTP requests — it only parses HTML that you provide. Authentication is handled by whichever function fetches the HTML (Web.Contents, Web.BrowserContents, File.Contents, etc.). Query folding is not supported.

    Compatibility note: Html.Table is not available in Power BI Service cloud refresh (it requires a gateway) or in Excel Online.

    Examples

    Example 1: Extract columns from a styled HTML table using class selectors

    ```powerquery

    let
        Html = Web.Contents("https://example.com/products"),
        Result = Html.Table(
            Html,
            {
                {"Product", "td.product-name"},
                {"Price",   "td.product-price"},
                {"Stock",   "td.product-stock"}
            },
            [RowSelector = "table.product-list tr"]
        )
    in
        Result

    Example 2: Extract link text and URLs from a list

    ```powerquery

    let
        Html = Web.Contents("https://example.com/resources"),
        Links = Html.Table(
            Html,
            {
                {"Label", "a"},
                {"URL",   "a[href]"}
            },
            [RowSelector = "ul.resource-list li"]
        )
    in
        Links

    Example 3: Parse a raw HTML string directly

    ```powerquery

    let
        RawHtml = "<table><tr><td>Apple</td><td>1.20</td></tr><tr><td>Banana</td><td>0.50</td></tr></table>",
        Result = Html.Table(
            RawHtml,
            {
                {"Fruit", "td:nth-child(1)"},
                {"Price", "td:nth-child(2)"}
            },
            [RowSelector = "tr"]
        )
    in
        Result

    Example 4: Chain with Web.BrowserContents for JavaScript-rendered pages

    ```powerquery

    let
        Html = Web.BrowserContents(
            "https://example.com/dynamic-data",
            [WaitFor = [Element = "table.results"]]
        ),
        Data = Html.Table(
            Html,
            {
                {"Name",  "td.name"},
                {"Score", "td.score"}
            },
            [RowSelector = "table.results tr.data-row"]
        )
    in
        Data

    Compatibility

    Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks