Select to view content in your preferred language

Survey123 Tricks of the Trade: Quick guide to modernize HTML formatting tags in your survey

30777
34
09-23-2021 12:05 PM
IsmaelChivite
Esri Notable Contributor
7 34 30.8K

Updated August 23 [Replaced div tags with span]

 

It is not news that using Survey123 Connect,  you can use HTML tags to format labels of questions, groups and even list choices an repeats.  Some popular uses for HTML formatting include:

  • Change the font color of a warning message to red to make it stand out
  • Center the label of a group and use a big font to create a nice header for a form section
  • Set the background color of a repeat group to help users navigate the form more easily
  • Change the font color of choices in a list

Many of you have reported that starting with version 3.13 your HTML formatting rules are being ignored in the Survey123 web application and website. Below is an example that recently came my way. Note how the HTML tags used to center the text (<center>) and to enlarge the font (<H3>) are being ignored and displayed as plain text. Not good!

 

IsmaelChivite_1-1632415500833.png

 

The reason for this is that version 3.13 enforces limits to the HTML tags you can use.  Tags you could use before are no longer allowed.  This change was enforced for consistency with the set of HTML tags supported by ArcGIS. The good news, is that the new set of HTML tags will likely let you do what you did before, and it is not that hard to modernize them.

Text color, size and alignment with span style

 

Use the span style to define the alignment, color, size and other properties of text.

For an introduction to span styles, check the WWW3 Schools guide. In short:

  • Enclose your text within a span tag. For example: <span>My Text</span>
  • Add the style property to the span. <span style="">My Text</span>
  • Add properties within the style following the syntax property:value; For example:
    • background-color:powderblue;  
    • color:blue;     Use any HTML color name or its hexadecimal equivalent (default is black)
    • text-align:center;  Use left, right or center (default is left or right depending on your locale)
    • font-size:large;  Use small, medium, large, x-large or xx-large (default is medium)
    • font-style:italic;  Use italic, normal or oblique (default is normal)
    • font-weight:bold;  Use normal or bold (default is normal)

It is important here to use a colon (:) to separate the name of the property (color, text-align, background-color) from the actual value. Do NOT use the equal sign!

If combining multiple properties within the style, make sure you separate them with semicolons (;)

There is no need to enclose color names with quotes. color:"blue" is incorrect. color:blue is correct.

The semicolon-separated list of property-value pairs you use within the style must be enclosed with quotes.

For example, this old school HTML:

<h3><center>Monoclonal Antibody (mAb)</center></h3>

Could look like:

<span style="text-align:center; font-size:large; font-weight: bold">Monoclonal Antibody (mAb)</span>

IsmaelChivite_0-1632420635145.png

This old HTML:

<center><font color='red'>Enter a date in the past</font></center>

Should look like:

<span style="text-align:center; color:red; ">Enter a date in the past</span>

Text colors, italic and bold

 

In truth, the <b> <i> and <font> tags continue to be supported. You can keep using them, or choose the span style syntax described above.

For example. This will continue to work:

<b><font color='blue'>Customer info</b> Will display text bold and blue

You can also alternatively use the equivalent span style properties.

<span style="font-weight:bold;color=red">Customer info</span> Will display the text with bold style

If you keep using <b> <i> and <font> or a <span style=""> instead is your call. I see the motivation for using <b> and <i> as they are not as verbose.  Using the <span> tag may help you in the long run keeping syntax more consistent in case you need to center the text or set a background color.

Background colors

 

You can set the background color of questions, notes and group labels. The old school HTML would look like this:

<body bgcolor="#f6beb2"><font color="#cd3212">You cannot enter a date in the future</font></body>

Again, you will want to use span styles now. The appropriate property is called background-color and it takes an HTML color name or an hexadecimal color value.

In the example below, I changed the color and weight of the text and applied a background color to the label of a note.

IsmaelChivite_0-1632422665137.png

 

The HTML syntax, applied to the label column of a note question, looks like this:

<span style="text-align:center; font-weight:bold; color:#cd3212;background-color: #f6beb2; ">You cannot enter a date in the future</span>

 

Other notes

 

The above shows the most common use cases for HTML formatting, but there are many more. You can use HTML to create breaklines in long labels, organize content into bulleted paragraphs and more.

For a complete list of all the HTML tags supported, read the HTML formatting section of the Style your survey help topic.

The Survey123 field app and Connect continue supporting old HTML tags. However, for maximum compatibility of your survey designs, I suggest keep the non-supported HTML tags behind.

 

 

 

34 Comments
Amanda__Huber
MVP Regular Contributor

@IsmaelChivite would it be worth making a ArcGIS Blog article about this for awareness? Our organization missed this memo and was directly affected by this seemingly sudden change.

abureaux
MVP Frequent Contributor

How do you define font size for the choices tab? <font> tags work, but <div> tags are ignored.

 

EDIT: I just realized that I made this post post. This is known behaviour: <div> and <span> don't work on the choices tab in Connect. You are stuck with the legacy HTML tags (such as <font>) for now.

DISIG
by
Regular Contributor

Hello everybody,

i am trying to migrate my styles with a test form before going further.

I have got a bad display in the webapp.

I use two calculations to change the font color and group background.

Everything is ok in the app.

if(selected(${civilite},'mme'),'DarkViolet ',if(selected(${civilite},'m.'),'blue',''))
if(selected(${civilite},'mme'),'Violet',if(selected(${civilite},'m.'),'LightSkyBlue ',''))

 

DISIG_0-1634555132863.png

The form look like this in web app 3.13 form (hmm... Not good!)

DISIG_1-1634555346110.png

and like this in the app (good!)

DISIG_2-1634555418716.png

 

LiamHarrington-Missin
Frequent Contributor

I'm also having some real trouble with this migration.  The web version seems to be ignoring style tags even when I copy the examples exactly. 

E.g. happening in the form_title (<div style="text-align=center; font-size:Large; "> Your Feedback</div>) doesn't center the text.  

abureaux
MVP Frequent Contributor

@LiamHarrington-MissinAre you using text-align=center (as it appears in your message) or text-align:center (this would be the correct format)?. Font size looks fine.

Pretty sure the final semicolon isn't actually needed, but it doesn't hurt to have it there.

LiamHarrington-Missin
Frequent Contributor

Thanks for checking @abureaux, I was playing with an alternative <div align="center" style="font-size:Large"... which I forgot to change back.  That didn't work either by the way. 

 However, now it reads  <div style="text-align:center; font-size:Large; "> Your Feedback</div> and it still remains left aligned once it gets to the web form.

It appears centred in the Survey123 Connect preview but as soon as I publish and view as a webform, back to the left hand side it goes. 

TaupoDistrict_Council
Frequent Contributor

I'm trying to format a calculated note but I'm getting errors. 

The label is successfully following the format I've typed, but the calculation isn't.  I've copied and pasted so there shouldn't be any typos!

How do I format my calculated note?

TaupoDistrict_Council_0-1637295186128.png

 

TaupoDistrict_Council
Frequent Contributor

Regarding my above question, I've resolved it by adding the calculation into the label so it is all one line now.

DanBihari
Regular Contributor

@LiamHarrington-Missin @abureaux

I'm having the exact same issue as Liam. I followed the article exactly, to the point where I literally copied and pasted the code.

<div style="text-align:center">Caller Address Information</div>

It shows up as left aligned in the web form and appears to completely ignore the tag.

It appears centred in the Survey123 Connect preview but as soon as I publish the changes the web form is back to the left hand side. 

DGiblin
Emerging Contributor

I have a note type field that is populated with a running list of values entered in a repeat, which allows the user to quickly see which items have been entered without needing to cycle back through the repeat.

Up through v3.12 I have been using join("\n",${species}) in the calculation field so that the note shows each record on its own line, making it much easier to read.

DGiblin_2-1645643895127.png

This method still works on the mobile app for v3.13, but now in the web form the note field simply prints all records on a single line with the \n text between each one.

DGiblin_1-1645643790543.png

Is there a way to replicate this setup with the new html codes (or some other method) that will work on both the mobile and web versions?

As far as I can tell the html tags do not work in a calculation, and I have not been able to come up with any way to replicate the setup that we have for v3.12.

Our data data collection uses the mobile app, and our QC process relies on using the web forms, so we need to have a setup that works well on both.

abureaux
MVP Frequent Contributor

@DGiblinHave you tried using <br>?

This isn't something I have tried in a text box though. Works well for notes.

DGiblin
Emerging Contributor

@abureaux  - Yes, I have tried to use <br>, but anytime I add that to the calculation it will either cause an error in the conversion if not in quotes, or if I place it in quotes then the resulting note contains that text instead of acting as a line break.

I have used <br> successfully in labels and hints, where the text values are static.
In those cases it works for both mobile and web versions of the form.

DISIG
by
Regular Contributor

Hello,

When i read this page, in the help of survey123 the body::esri:style can be use to change the bakground color of a group. It works fine in the fieldapp but not in the webapp. Is it a limitation or the style must be migrated too?

I use succesfully  this symbols ☑ ✐ in the field app by pushing them dynamically the field label. It works fine in the fieldapp but not in the webapp. Is it a limitation or the style must be migrated too?

InesPereda
New Contributor

Hey! Im also finding issues while applying styles to the Webapp when designing in connect. And can't seem to center images either. 

InesPereda_0-1676883224404.png

Image1: Connect. Looks nice and how I've intented it to be 😎

InesPereda_1-1676883351920.png

Image 2: Webb. Looks awful (🤣

Code (sorry....first time with HTML)

<div style="font-size:20px;">Hi and welcome! We would like to be able to contact people that are interested to participate in the <b>WA Birds on Farms Project</b>. You could be wanting to sign in as: <ul style="list-style-type:disc;">
<li>A volunteer to carry out surveys,</li>
<li>Somone that owns a property and wants to register their farm for surveys or,</li>
<li>You are just interested in knowing more about the project</li></div>
<div style="font-size:12px">This information is safe with the WA Woodland Birds Team, and will only be used for Birds on Farms related events and news </div>

 

 

AlexanderCrocker
New Contributor

Can anyone please explain or provide a good source on how to auto populate a field in Survey123? We are trying to auto populate the asset id when the user selects the hyperlink from the popup to take the survey of the asset.  We would then like the asset id to be showing in the survey when it is opened. 

Thank you for any assistance ! 

DJB
by
Regular Contributor

Hey @AlexanderCrocker ,

I assume that you want to click on a feature and then have attribute(s) be passed from that feature to your survey.  If that's the case use the following code:

https://survey123.arcgis.com/share/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX?field:ParentGlobalID={GlobalID}&fie... 

Survey Link + "?field:" + the field in your survey that you want to populate + {the field in the feature that holds the data you want to pass}

Hope that helps

~Dan

AlexanderCrocker
New Contributor

Hi Dan, Thank you for your response.  Where is this code then entered to execute ? We are using Survey 123 Connect. 

DJB
by
Regular Contributor

@AlexanderCrocker ,

I actually have it tied to a web map and the code is part of the feature service pop-up.  So for the example the code I gave you, all of the surveys are tied to a county so when they click on the county of interest, that's what is passed to the survey.

Survey123 Tricks of the Trade: Web form URL parame... - Esri Community

Integrate with other apps—ArcGIS Survey123 | Documentation (this is a real good source)

~Dan

AlexanderCrocker
New Contributor

Thank you so much for your assistance! 

Todd
by
Regular Contributor

Hi @IsmaelChivite and GeoFriends,

I have an older Survey123 Connect XLS that is failing the new HTML requirements. I'm using the following calculation to concatenate a URL creating a custom hyperlink for Google Maps: 

concat('Map: ','<a href=','"https://www.google.com/maps/place/@',${loc_lat},',',${loc_lon},',17z"',' target=','"_blank"','>Google</a>')

 Could someone point me in the direction to assist with correcting these errors?

WarningThe "https: attribute is not supported for the a HTML tag.The "https: attribute is not supported for the a HTML tag. This element may not be visible on the form.
WarningThe www.google.com attribute is not supported for the a HTML tag.The www.google.com attribute is not supported for the a HTML tag. This element may not be visible on the form.
WarningThe maps attribute is not supported for the a HTML tag.The maps attribute is not supported for the a HTML tag. This element may not be visible on the form.
WarningThe place attribute is not supported for the a HTML tag.The place attribute is not supported for the a HTML tag. This element may not be visible on the form.
WarningThe @',${loc_lat},',',${loc_lon},',17z"',' attribute is not supported for the a HTML tag.The @',${loc_lat},',',${loc_lon},',17z"',' attribute is not supported for the a HTML tag. This element may not be visible on the form.
WarningThe target attribute is not supported for the a HTML tag.The target attribute is not supported for the a HTML tag. This element may not be visible on the form.
WarningThe "_blank"',' attribute is not supported for the a HTML tag.The "_blank"',' attribute is not supported for the a HTML tag. This element may not be visible on the form.

 

Thanks in advance,

Todd

 

ChuckS
by
Occasional Contributor

I previously used html for some items in many of my choice lists. I discovered that html code appears in the label for the field in the feature layer. It seems like that might be a bug.

I will now avoid using html items in my choice lists. See the following post for more info.

Using html for choices in select_one list

 

JillHalchin
Frequent Contributor

@IsmaelChivite I'm working with Connect verion 3.16.110.  When I updated an older spreadsheet, it became version 3.19.  When working to update the html, I found that I have to use <div> instead of <span> for a Group.  I noticed that you originally wrote your post using <div>, then updated is last year. Do I need to use <div> because of our Connect version?  

abureaux
MVP Frequent Contributor

@JillHalchin<span> should work fine in groups. What isn't working exactly?

The only thing that I can think of off-hand that wont work is the center tag. A <span> is as large as the content it contains, whereas a <div> is always the width of the page.

abureaux_0-1704726972237.png

 

 

mikaël
Frequent Contributor

Hey, any way to apply html to hint and guidance hints text in Connect and app?

text-align and font-weight doesn't seem to do anything, but they are working in the web version.

Thanks!

abureaux
MVP Frequent Contributor

Hint accepts HTML formatting just fine. Double-check your syntax. If "center" wasn't working, ensure you are using a DIV and not a SPAN.

<div style="font-weight:bold;text-align:center">Text</div>

 

Guidance Hint is a little different. It doesn't accept HTML formatting. But, you can apply guidance hint text to a question with a hint. That way, the display text (the Hint) will have HTML formatting, but the popup on click (Guidance Hint) will be plain text.

mikaël
Frequent Contributor

@abureaux, right, thanks for that, div does work for hint, my bad.

Concerning guidance hint, what do you mean you can "apply guidance hint texto to a question with a hint"  ?

I wish to enter details about the values that can be selected, not something that has to be seen everytime, but more like a reference, which is why I was thinking guidance hint. Something formatted like this:

value 1: details on value 1

value 2: details on value 2

value 3: details on value 3

and so on.

 

Thanks!

 

 

abureaux
MVP Frequent Contributor

@mikaëlPoor wording on my part. What you are describing will work.

Essentially, add text to a "hint" cell and give it any formatting you desire. Then, toss some plain text into the "guidance hint" cell.

One note: Unfortunately, the "guidance hint" does have a text limit (and a fairly low one, if memory serves). I believe there is a post in the Ideas thread to expand that limit. If you run into this limit, there isn't a way to bypass it.

mikaël
Frequent Contributor

@abureaux 

Thanks, ended up creating a group to give details on the values, as is explained in the Ideas thread you mention.

CarissaFoley
Emerging Contributor

So I tried to follow these guidelines for my survey but I am still seeing below in the web version of my survey for the group headers:

CarissaFoley_0-1727466842532.png

I have a calculated value that turns the header a different color depending on the status of the project. The labels look as follows: <span style="color:${PSUColor1}">PSU Forms</span>

Any insight would be super helpful. Thank you!

abureaux
MVP Frequent Contributor

Try replacing ${PSUColor1} with a color (e.g., Red or #FF0000). Do you still see the issue? If so, check the calculation for ${PSUColor1} for errors.

CarissaFoley
Emerging Contributor

@abureaux so that was a good idea to test, thank you! When I subbed in the color, it looked as intended. However, there are no errors being thrown in my ${PSUColor1} calculation when I look at it. It reads as follows in the calculate field:

if(selected(${PSUStatus1}, 'NotYetInProgress'),'Red', if(selected(${PSUStatus1},'InProgress'),'Orange',if(selected(${PSUStatus1},'Submitted'),'Gold',if(selected(${PSUStatus1},'Approved'),'Green'))))

 

It works fine in Connect, but it is when I publish it and open it on the web that it looks like what I had posted initially. The user basically selects one option from the "Status" field, and then the heading color is supposed to change depending on that status selection.

abureaux
MVP Frequent Contributor

Your IF() statement has an error. Missing the final IF False (see below). Is that how you have it entered in Connect? Connect should have picked up on that (so wondering if it's out of date).

if(selected(${psustatus1}, 'NotYetInProgress'),'Red', if(selected(${psustatus1},'InProgress'),'Orange',if(selected(${psustatus1},'Submitted'),'Gold',if(selected(${psustatus1},'Approved'),'Green',''))))

Beyond that, the issue is that the Web Form appears to not support calculates in Group labels it seems. Honestly, I could have sworn they did.

It is supported in regular text though:

abureaux_4-1727711551099.png

 

If a new line of text doesn't work, you could try emojis as an alternative for the Group label:

abureaux_3-1727711330888.png
abureaux_2-1727711317464.png

 

abureaux
MVP Frequent Contributor

Sorry, one more thing (I did this without thinking...). You need to cram everything into the calculate for it to work in the web:

if(selected(${psustatus1}, 'NotYetInProgress'),'<span style="color:Red">PSU Forms</span>', if(selected(${psustatus1},'InProgress'),'<span style="color:Orange">PSU Forms</span>',if(selected(${psustatus1},'Submitted'),'<span style="color:Gold">PSU Forms</span>',if(selected(${psustatus1},'Approved'),'<span style="color:Green">PSU Forms</span>','PSU Forms'))))

CarissaFoley
Emerging Contributor

@abureaux thank you for the guidance, I may need to go that route if it is continuing to show up poorly on the web. Either that or move some of my folks into Survey123 on the desktop. So the groups I currently have like the "PSU Forms" group are actually nested within a larger group, so I wonder if that itself could be causing issues as well. I will take a try at what you have provided and see how I do. Thank you!