Introduction👨✈
In web2py, there are HTML helpers, built in helpers, and custom helpers. In this article, we will only learn about built in helpers in web2py. We will see various types of built in helpers in web2py and learn to use them with examples.
Are you ready❓

So let us learn about built in helpers in web2py.💫
Built-in helpers✅
A📌
"A" helper is used to build links. Write the following line in view.
{{=A('Click on this link.', _href='http://sitename.domain')}}

ASSIGNJS📌
"ASSIGNJS" allows a value on the server side to be used as a client-side js(javascript) value.
For example - if in a controller, you write the following.
return dict(stra='xyz', object=val)
and in a view, you write.
<script>
{{=ASSIGNJS(jsvar=object)}}
…
Then the "jsvar" (javascript variable) will have the value "val" (which is the value passed in the "obj").
B📌
"B" helper makes the contents bold. Write the following line in view.
{{=B('This content is BOLD')}}

BODY📌
The "BODY" helper makes the body of the page. Write the following line in view.
{{=BODY('This helper will make the body of the page.')}}

BR📌
The "BR" helper creates a line break. Write the following line in view.
{{=B('There is 1 line break after this line.')}}
{{=BR()*1}}
{{=B('This statement is after line break.')}}

CAT📌
"CAT" concatenates other helpers. "CAT" is used in the following statement to concatenate "A" and "B".
{{=CAT('This is ', A('link', _href='http://sitename.domain'), ' and this is ', B('bold'), '.')}}

CENTER📌
"CENTER" helper centres its content. Write the following line in view.
{{=CENTER('This text is in center')}}

CODE📌
"CODE" helper performs syntax highlighting for C, C++, Python, web2py code and HTML and is preferable to PRE for code listings. "CODE" can also create links to the web2py API documentation. Write the following line in view.
For example1 -
{{=CODE('printf("Printing something in C");', language='c')}}

For example2 -
{{=CODE('print "print something in python"', language='python')}}

COL and COLGROUP📌
It will be much easier to understand if we discuss COL and COLGROUP from the HTML perspective. The HTML element <col> defines a column within the table. It is generally used within an <colgroup> element. The HTML element <colgroup> defines a group of columns within the table.
Write the following line in view.
{{=COLGROUP('a', 'b', 'c', 'd')}}
{{=COLGROUP('e', 'f')}}
{{=COLGROUP('g', 'h', 'i')}}
{{=COLGROUP('j', 'k', 'l', 'm', 'n')}}

DIV📌
"DIV" helper corresponds to HTML element <div>. Write the following line in view.
{{=DIV('This text is in div element')}}
{{=B('This text is outside div element')}}

EM📌
"EM" helper emphasises its contents. Write the following line in view.
{{=EM('EM will emphasise this content.')}}

FIELDSET📌
The "FIELDSET" helper creates an input field together with its label. Write the following line in view.
{{=FIELDSET('FIELDNAME : ', INPUT(_name='fieldname'))}}

FORM📌
"FORM" helper makes a <form>...</form> tag and can process the submitted forms (for example, perform validation of the fields). Write the following line in view.
{{=FORM(INPUT(_type='submit'))}}

H1, H2, H3, H4, H5, H6📌
"H1", "H2", "H3", "H4", "H5", "H6", etc. helpers are used for headings and subheadings. Write the following line in view.
{{=H1('Heading1')}}
{{=H2('Heading2')}}
{{=H3('Heading3')}}
{{=H4('Heading4')}}
{{=H5('Heading5')}}
{{=H5('Heading6')}}

HEAD📌
The "HEAD" helper is used to tag the HEAD of an HTML page. Write the following line in view.
{{=HEAD(TITLE('THIS IS TITLE'))}}

HTML📌
The "HTML" built in helper makes the <html> tags; it prepends the tag with a doctype string[xhtml-o,xhtml-w,xhtml-school]. Write the following line in view.
{{=HTML(BODY('something in Body'))}}

The HTML helper takes some additional optional arguments having the following default.
HTML(..., lang='en', doctype='transitional')
where doctype can be 'transitional', 'strict', 'frameset', 'html5', or a full doctype string.
XHTML📌
The "XHTML" helper is similar to HTML but creates an XHTML doctype instead, where the doctype can be 'transitional', 'strict', 'frameset', or a full doctype string.
HR📌
The "HR" helper creates a horizontal line in an HTML page. Write the following line in view.
{{= HR()}}

I📌
"I" helper makes its contents italics. Write the following line in view.
{{=I('Italic Content')}}

IFRAME📌
The "IFRAME" helper includes another web page(the URL of this page is specified via the "_src" attribute) on the current page. Write the following line in view.
{{=IFRAME(_src='https://www.codingninjas.com/')}}

IMG📌
"IMG" helper is used to embed images into HTML. Write the following line in view.
{{=IMG(_src='https://files.codingninjas.com/google-12193.png', _alt='google')}}

INPUT📌
The "INPUT" helper creates an <input.../> tag. The input tag has an optional attribute _type which can be set to "text" (the default), "checkbox", "submit", or "radio". Write the following line in view.
{{=INPUT(_name='name', _value='value')}}

LABEL📌
The "LABEL" helper creates a LABEL tag for an INPUT field. When you want to click the text within the <label> element, it toggles the input (this increases the hit area). Write the following line in view.
{{=INPUT(_type='checkbox', _id='0', _value='ninja course')}}
{{=LABEL('Coding Ninjas Course', _for='0')}}

LEGEND📌
The "LEGEND" helper creates a legend tag for a field in a form. Write the following line in view.
{{=FIELDSET(LEGEND('This is Legend'))}}

LI, OL and UL📌
"LI" makes a list item, and it should be contained in an "OL" or "UL" tag. Write the following line in view.
{{=P('Ordered List')}}
{{=OL(LI('C'), LI('C++'), LI('Python'))}}
{{=P('Unordered List')}}
{{=UL(LI('C'), LI('C++'), LI('Python'))}}

Note ⚠️- OL stands for the ordered list, UL stands for an unordered list, and the list should contain LI tags. If the content is not tagged as LI, OL/UL does it automatically.
META📌
"META" is used for building META tags in the HTML head. Write the following line in view.
{{=HEAD(META(_name='priority', _content='urgent'))}}
{{=BODY('Built in Helpers in web2py: A to Z')}}
{{=LI('Meta informations are present in head')}}

MARKMIN📌
"MARKMIN" built in helper uses Markmin wiki syntax. It changes the input text into output HTML using the markmin rules. Write the following line in view.
{{=MARKMIN("This is **bold text** , ''italic'' and this is [[Coding Ninjas. https://www.codingninjas.com/]]")}}

Here is a basic syntax primer.⚠️

OBJECT📌
"OBJECT" embeds objects in the HTML(for example, a flash player). Write the following line in view.
{{=OBJECT('Object built in helper', _src='https://www.codingninjas.com/')}}

ON📌
"ON" is for backward compatibility and is simply an alias for "True". It is used exclusively for checkboxes and deprecated as "True" is more Pythonic.
OPTGROUP📌
The "OPTGROUP" helper allows to group together multiple options in a "SELECT". Write the following line in view.
{{=SELECT('OPTION1', OPTGROUP('OPTION2', 'OPTION3'))}}

OPTION📌
"OPTION" should only be used as part of an OPTION/SELECT combination. Write the following line in view.
{{=SELECT(OPTION('a'), OPTION('b'))}}

P📌
"P" tags a paragraph. Write the following line in view.
{{=P('This is a paragraph')}}

PRE📌
"PRE" helper generates a <pre>...</pre> tag for displaying pre-formatted text. Write the following line in view.
{{=PRE('2-SPACES AFTER THIS:', ' ', '2-SPACES BEFORE THIS:')}}

SCRIPT📌
"SCRIPT" helpers include or link a script(for example, JavaScript). The content between this tag will be rendered as an HTML comment. Write the following line in view.
{{=SCRIPT('alert("Coding Ninjas");', _type='text/javascript')}}

SELECT📌
"SELECT" makes a <select>...</select> tag. "SELECT" is used with the "OPTION" helper. Those "SELECT" arguments that are not objects of "OPTION" are automatically converted to options. Write the following line in view.
{{=SELECT('Coding', 'Ninjas')}}

SPAN📌
The "SPAN" helper is used to tag inline content. Write the following line in view.
{{=SPAN('SPAN', _style='border:2px solid orange')}}

STYLE📌
The "STYLE" helper is used to define style information. Here you define how the HTML elements will render inside your browser. Write the following line in view.
{{=STYLE('H1 {color:blue;}')}}
{{=BODY(H1('This is a heading.'))}}

TABLE, TBODY, TFOOT, TH, THEAD, TD and TR📌
These tags (along with the optional THEAD, TBODY and TFOOT helpers) are used to build HTML tables. Write the following line in view.
{{=TABLE(TR(TD('S'), TD('A')), TR(TD('N'), TD('C')))}}
{{=THEAD(TR(TH('THEAD tags table header rows')))}}
{{=BR()}}
{{=TFOOT(TR(TD('TFOOT tags table footer rows')))}}
{{=BR()}}
{{=TBODY(TR('TBODY tags rows contained in the table body'))}}
{{=BR()}}
{{=TR(TD('TR tags a table row'))}}
{{=BR()}}
{{=TH('TH is used instead of TD in table headers.')}}
{{=BR()}}
{{=TD('TD tag defines a standard data cell in the HTML table.')}}
{{=BR()}}
{{=TR('TR tag defines a row in the HTML table.')}}

TEXTAREA📌
"TEXTAREA" helper makes a <textarea>...</textarea> tag.
{{=TEXTAREA('This is written inside the textarea.')}}

TITLE📌
"TITLE" tags the title of a page in an HTML header. Write the following line in view.
{{=TITLE('This is Title')}}

TT📌
"TT" tags text as monospaced(typewriter) text. Write the following line in view.
{{=TT('monospaced text')}}

URL📌
The "URL" helper generates internal URL paths for the actions and the static files. Write the following line in view.
{{=URL('path')}}
{{=BR()}}
{{=B("The URL('path') is mapped into - ")}}
{{=B('/[application]/[controller]/path')}}

embed64📌
The "embed64" helper encodes the provided (binary) data into base64; it takes the following arguments(optional).
⚡filename: opens and reads this file in 'rb' mode if provided.
⚡file: reads this file if provided.
⚡data: uses the provided data if provided.
🧷embed64(filename=None, file=None, data=None, extension='image/gif')
xmlescape📌
The "xmlescape" built in helper, xmlescape(data, quote=True), returns the escaped string of the provided data. Write the following line in view.
{{=xmlescape('<escape>')}}

Alright! We hope you now understand the built in helpers in web2py.