How do I style paragraphs in a field?
This lesson applies to version 5.5 and later of LiveCode.
Create a stack with a field of text
![Create a stack with a field of text](https://media.screensteps.com/image_assets/assets/001/188/678/original/media_1332260123677.png)
In all of the following steps we'll be looking at how to manipulate the second paragraph (or line 3 of field "content"). Each step will have a line of two of code and a screenshot of the results.
Center align our paragraph (textAlign Property)
![Center align our paragraph (textAlign Property)](https://media.screensteps.com/image_assets/assets/001/188/680/original/media_1332260157106.png)
set the textAlign of line 3 of field "content" to "center"
Highlight our paragraph (backgroundColor property)
![Highlight our paragraph (backgroundColor property)](https://media.screensteps.com/image_assets/assets/001/188/681/original/media_1332260330706.png)
set the backgroundcolor of line 3 of field "content" to "200,180,241"
Give our paragraph a strong border (borderWidth and borderColor properties)
![Give our paragraph a strong border (borderWidth and borderColor properties)](https://media.screensteps.com/image_assets/assets/001/188/676/original/media_1332260690138.png)
set the bordercolor of line 3 of field "content" to "30,30,30"
set the borderwidth of line 3 of field "content" to 5
Pad our paragraph from its border (padding property)
![Pad our paragraph from it's border (padding property)](https://media.screensteps.com/image_assets/assets/001/188/679/original/media_1332260834221.png)
set the padding of line 3 of field "content" to 15
Indent the first line of our paragraph (firstIndent property)
![Indent the first line of our paragraph (firstIndent property)](https://media.screensteps.com/image_assets/assets/001/188/677/original/media_1332260981712.png)
set the firstindent of line 3 of field "content" to 40
Indent our paragraph (leftIndent and rightIndent properties)
![Indent our paragraph (leftIndent and rightIndent properties)](https://media.screensteps.com/image_assets/assets/001/188/675/original/media_1332261153770.png)
set the rightIndent of line 3 of field "content" to 30
set the leftIndent of line 3 of field "content" to 30
Add space above and below our paragraph (spaceBefore and spaceAfter properties)
![Add space above and below our paragraph (spaceBefore and spaceAfter properties)](https://media.screensteps.com/image_assets/assets/001/188/682/original/media_1332261271054.png)
set the spaceAbove of line 3 of field "content" to 18
set the spaceBelow of line 3 of field "content" to 18
Summary
All of the above steps can be gathered into a single routine to set the style of a particular run of text such as the paragraph in this example:
set the textalign of line 3 of field "content" to "center"
set the backgroundcolor of line 3 of field "content" to "200,180,241"
set the bordercolor of line 3 of field "content" to "30,30,30"
set the borderwidth of line 3 of field "content" to 5
set the padding of line 3 of field "content" to 15
set the firstindent of line 3 of field "content" to 40
set the rightIndent of line 3 of field "content" to 30
set the leftIndent of line 3 of field "content" to 30
set the spaceAbove of line 3 of field "content" to 18
set the spaceBelow of line 3 of field "content" to 18
Sean Cole
You can also change many other properties like 'textSize', 'textFont' or 'textStyle["Bold"] in a similar way using 'item', 'word', 'char' and so on. You could therefore highlight individual words based on a search.
Charles Szasz
I have run into problems using styled paragraph with Window for printing. Text including letters and word overlapped during printing. This does not occur on the Mac. Is there a solution for this problem?
Charles Szasz
How do you first indent a paragraph so that subsequent paragraphs are first indented?
Elanor Buchanan
Hi Charles, if you want each paragraph to be first indented you would do
set the firstindent of line 1 to -1 of field "content" to 40
This will indent the first line of each paragraph.
I hope that helps.
Elanor
Elanor Buchanan
Hi Charles,
Could you please report the printing issue on Windows as a bug with a recipe and/or sample stack at
https://quality.livecode.com/
From there the team will investigate the problem.
Thank you.
Elanor