Get Div Block element tag

element.getTag()

Retrieve the element tag of a Div Block element.

Syntax

1element.getTag(): Promise<null | BlockElementTag>

Returns

Promise<null | BlockElementTag>

A Promise that resolves to one of the following:

  • BlockElementTag: The Block element tag, including div, header, footer, nav, main, section, article, aside, address, or figure
  • null: If the element is not found or the Block element tag is not set

Example

1// Get a Div Block element
2const el = await webflow.getSelectedElement();
3
4// Set its element tag to main
5if (el.type === 'Block') {
6 // Get the current element tag
7 const elementTag = await el.getTag();
8 if (elementTag !== 'main') {
9 // Set the element tag
10 await el.setTag('main');
11 }
12}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAn