# HTML

Generating HTML templates and extracting data from HTML.

---

## Operations

The HTML node supports two main operations for working with HTML content:

### Generate HTML Template

Create HTML content using a template with support for dynamic expressions.

#### Configuration Options:
- **HTML Template**: The HTML content to render, supporting:
  - HTML5 tags
  - `<style>` tags for CSS
    - inline styles
    - css classes
  - Dynamic expressions using `{{ }}` syntax
    - Can use `$` to refer to built-in functions and properties
 - built-in funcs: `$if(cond, true-result, false-result)` to conditionally render content, `$max(a, b), $min(a, b)` for numeric comparisons
 - `$json` to access JSON properties from input data
 - i.e. `={{ $if($json.id!=1, true, false) }}`
    - Only expressions inside `{{ }}` are evaluated, not declarations or assignments

### Extract HTML Content

Extract specific content from HTML using CSS selectors.

#### Source Data Options:
- **Binary**: Read HTML from binary data
  - Binary Property: Name of the binary property containing the HTML (required)

- **JSON**: Read HTML from JSON data
  - JSON Property: Name of the JSON property containing the HTML string or array of strings (required)

#### Extraction Configuration:
- **Extraction Values**: Define what data to extract (multiple values supported)
  - Key: Name for the extracted value
  - CSS Selector: The CSS selector to target elements (e.g., ".price")
  - Return Value Type:
    - Text: Get only text content
    - HTML: Get the HTML content
    - Attribute: Get specific attribute value
    - Value: Get value of form elements (input, select, textarea)
  - Attribute Name: When returning attribute value, specify the attribute
  - Return Array: Option to return multiple matches as an array

### HTML Table Options

When working with HTML tables, the following options are available:

- **Caption**: Add a caption to the table
- **Capitalize Headers**: Option to capitalize table headers
- **Custom Styling**: Enable custom table styling
- **Table Attributes**: Custom attributes for the table element
- **Header Attributes**: Custom attributes for header cells
- **Row Attributes**: Custom attributes for table rows
- **Cell Attributes**: Custom attributes for table cells

## Notes

- When using the Generate HTML Template operation, you can include CSS and JavaScript, though JavaScript won't be executed
- CSS selectors in Extract HTML Content support standard CSS selector syntax
- Binary and JSON properties must be properly specified for extraction to work
- Multiple extraction values can be configured to extract different pieces of content in a single operation
