This HTML5 branding tutorial is designed to teach you the basics of using CSS and a Layout's settings to customize the look and feel of an HTML5 Help Center. For the tutorial, we are focusing on an article page in a Help Center, but you can use the same principles to customize other pages.
The tutorial is not a comprehensive guide to customizing every part of an HTML5 Help Center. Also, while we explain some CSS basics, it is not a guide to using CSS.
To complete the tutorial, you need:
-
Paligo instance with full author license.
-
A logo image file for your organization.
-
A code editor or text editor that can save CSS files, such as Atom, Notepad ++, BBEdit, Brackets, VisualStudio Code. (Other editors are available).
-
A modern browser, such as Google Chrome or Mozilla FireFox.
-
A basic understanding of the browser's Inspection Tool, see Browser Inspection Tool.
We also expect you to understand the basics of creating content in Paligo, including how to:
-
Create publications and topics
-
Add topics to a publication
-
Create paragraphs, tables, lists, procedures, subsections (sections inside another section)
-
Add images to a topic.
During the branding HTML5 Help Center tutorial, you will learn how to customize the look and feel of a regular article page in an HTML5 Help Center. This involves:
-
Using a browser's Inspection tool to view the HTML and test changes to the CSS
-
Using different selectors and rules in CSS
-
Applying attributes to elements in Paligo
-
Creating class names
-
Uploading a custom CSS to a Layout
-
Uploading a logo to a Layout.
Ready to get started? Let's begin with Prepare a Sample Topic and CSS.
Note
The tutorial only covers using CSS to style for a browser on a desktop. For mobile devices, you can use media queries in your CSS. There are many online resources for learning about media queries, such as w3schools.com.
First, let's create a topic with some sample content that you can style in the later stages of the tutorial. You will also add the topic to a publication.
-
Create a sample topic containing:
-
Title
-
Two paragraphs (para)
-
Procedure with some steps
-
Bullet list (unordered list)
-
Nested bullet list (a bullet list inside a list item in another "parent" bullet list).
-
Number list (ordered list)
-
Image
-
Table
Create a table that has 4 rows, 4 columns and a header. Enter some text or numbers in each cell.
-
A subsection
For the tutorial, use the Element Context Menu to add a
section
,title
, andpara
element into the topic directly. -
A subsection of the subsection
Use the Element Context menu to add a
section
,title
, andpara
element inside the previous section.
-
-
Select the second
para
element and use the Element attributes panel to give it therole
attribute. Set the value of therole
attribute to:indentbody
When you publish, Paligo will give the paragraph the class name "indentbody" in the HTML. You can then style it using CSS.
-
Select the
table
element and use the Element attributes panel to give it therole
attribute. Set the value of therole
attribute to:data-table
When you publish, Paligo will create a
div
element to contain the table. Thediv
element will have the class name "data-table" and you can style it by using CSS. -
Select the last cell in your table. In the Element Structure Menu at the top, select the
td
element and then Go to element from the menu. Use the Element attributes panel to give thetd
element theclass
attribute and set its value to:yellow-cell
When you publish, Paligo will give this cell the class name "yellow-cell". You can then style it using CSS.
-
Save your sample topic.
-
Create a publication, add your sample topic to it, and then save it.
-
Select the dotted menu ( ... ) for your publication and then select Publish.
Publish your publication and use the built-in default HTML5 Help Center Layout.
-
Select HTML5 and choose the default HTML5 Help Center Layout.
-
Select Publish document.
Paligo publishes your publication and it downloads as a zip file in your browser.
-
Open the zip file and browse to the out folder. Open the index.html file in a browser. For this tutorial, we are using Google Chrome.
-
Select the panel for your sample topic to open it.
-
Create a CSS file. You can use any third-party text editor or code editor that supports saving a CSS file. Leave the editor open so that you can add CSS to it as you work through this tutorial.
Next: Style the TOC Sidebar.
Example 2. Sample topic
Your sample topic should look similar to this:
If you select Edit and then < / >, you can see the source code of your sample page. It should look similar to the following XML. We have removed the xml ids and section attributes for clarity, as Paligo adds those automatically, but you may see them in your source code.
Source code:
<?xml version="1.0"?> <section> <title>Sample Content</title> <para>This is a regular paragraph.</para> <para role="indentbody">This is an indented paragraph.</para> <procedure> <step> <para>This is step 1</para> </step> <step> <para>This is step 2.</para> <procedure> <step> <para>This is a nested step.</para> </step> </procedure> </step> </procedure> <itemizedlist> <listitem> <para>Itemized list (bullet list)</para> </listitem> <listitem> <para>Itemized list 2</para> <itemizedlist> <listitem> <para>Nested itemized list</para> </listitem> </itemizedlist> </listitem> </itemizedlist> <orderedlist> <listitem> <para>Ordered list</para> </listitem> <listitem> <para>Ordered list step 2</para> <orderedlist> <listitem> <para>This is a nested list item.</para> </listitem> </orderedlist> </listitem> </orderedlist> <mediaobject> <imageobject> <imagedata fileref="UUID-39efc9ab-ba22-da66-200c-b8324c2aabd2" width="25%"/> </imageobject> </mediaobject> <table class="data-table" frame="border" rules="all"> <caption>table title</caption> <thead> <tr> <th> <para>Column A</para> </th> <th> <para>Column B</para> </th> <th> <para >Column C</para> </th> <th> <para>Column D</para> </th> </tr> </thead> <tbody> <tr class="green-row"> <td> <para>1</para> </td> <td> <para>2</para> </td> <td> <para>3</para> </td> <td> <para>4</para> </td> </tr> <tr> <td> <para>5</para> </td> <td> <para>6</para> </td> <td> <para>7</para> </td> <td> <para>8</para> </td> </tr> <tr> <td> <para>9</para> </td> <td> <para>10</para> </td> <td> <para>11</para> </td> <td> <para>12</para> </td> </tr> <tr> <td> <para>13</para> </td> <td> <para>14</para> </td> <td> <para>15</para> </td> <td class="yellow-cell"> <para>16</para> </td> </tr> </tbody> </table> <section> <title>Sub-section level 1</title> <para>Para in sub-section 1.</para> <section> <title>Sub-section level 2</title> <para>Para in sub-section level 2.</para> </section> </section> </section>
The table of contents (TOC) is shown in a sidebar and has a blue background, by default. Let's change the color.
-
Right-click in the browser window and select Inspect*.
*This is correct for Google Chrome. Other browsers may use a different name.
-
Use the Inspect tool in the Browser Inspection Tool.
-
Move the cursor over the TOC sidebar so that the entire bar is highlighted and then left-click to select it.
-
In the Styles, find the rule that is setting the background color.
-
Select the color box and change the color to:
#a94442
The background color of the TOC changes in the browser.
-
Right-click on the rule that you changed in steps 4 and 5 and select Copy Rule.
-
Paste the rule into your CSS file (from Prepare a Sample Topic and CSS).
It is best practice to add comments to your CSS so that anyone who opens the CSS file can tell what each rule is styling. To start a comment, enter /* and to end a comment enter */
Here is an example of a comment before a rule:
/* The following rule changes the background color of the sidebar */ .bg-primary, .btn-primary, .pagination>.active>a, .pagination>.active>span, .pagination>.active>a:hover, .pagination>.active>span:hover, .pagination>.active>a:focus, .pagination>.active>span:focus, .site-sidebar, .portal-single-publication .publication-icon { background-color: #a94442; }
Now let's change the color and style of the headings and paragraphs.
-
Use the Inspect tool in the Browser Inspection Tool to select the main heading on the page.
-
In Styles, find the rule that sets the heading 2 (h2) font-size and increase the size to 40px.
-
Click on the line below the font-size property and add a color property with the value set to #a94442. Remember to add a semi-colon at the end of the color value.
This sets the main heading to match the color of the TOC side bar.
-
Add another rule to the same class. This time set the font-weight to 800. Again, remember to add a semi-colon after the font-weight value.
-
Right-click on the rule in the Styles panel and select Copy rule.
-
Paste the rule into your CSS file, after the closing curly bracket of the previous rule.
-
Using the same technique, set your:
-
sub-headings to the same color as your main heading
.h3, h3 { font-size: 28px; color:#a94442; } .h4, h4 { font-size: 28px; color:#a94442; }
-
paragraph to medium font-size
p { font-size: medium; }
-
-
Copy and paste these rules into your CSS file.
Next: Style Procedure Numbers.
Now let's change the style of the procedure step numbers. We will change the background color to a dark red (#a94442).
-
Use the Selector tool in the Browser Inspection Tool to select a step in a procedure.
-
In the Styles, select the
::before
that comes immediately after the selected<li class="step">
. The::before
is a pseudo element and, in this case, it represents the step number icon. -
Change the background color:
.theme1 .procedure > li::before { background-color: #a94442; }
-
Copy the rule and paste it into your CSS file.
Next: Style the Images.
Now let's apply some styling to bullet lists at the top level and also a nested bullet list (second level list).
-
Use the Selector tool in the Browser Inspection Tool to select an item in a top-level bullet list (itemized list).
-
In Styles, select the
::marker
that comes between the<li class="listitem">
and the<p>
.Notice that the
::marker
has some rules that come from "user agent stylesheet". This means it is using the default styling that is defined by the browser. You cannot change these, but any rules that you add for the same class will override the browser defaults. -
Select the plus icon on the Styles toolbar to add a new rule. It automatically includes the selector (in this case,
::marker
). -
Edit the selector and create this rule:
.itemizedlist ul.itemizedlist > li::marker { color: ##a94442; font-size: 1.2em; }
Here, you are making the selector more specific and setting a color and size for the bullet points. The browser will only apply the styles to markers that are located in this structure:
<element with class = itemizedlist> <ul with class = itemizedlist> <li>
The bullet points for the list change color to dark red and become larger.
-
Copy the rule and add it to your CSS.
-
Select a bullet list and look in the HTML. It shows that the
<ul>
HTML contains inline styling, in this case, it is setting the bullet lists to use a disc bullet.The browser will use this styling in preference to the CSS. To tell the browser to use a style in your CSS instead, you can include
!important
. This should be used carefully, as it tells the browser to use the!important
style in preference to any other styling, including styling in other CSS files. -
In Styles, select the plus icon + and add this new rule:
.itemizedlist > ul.itemizedlist { list-style-type: square !important; }
This tells the browser to use square bullets on top-level unordered lists.
-
Copy the rule and add it to your CSS.
-
Now let's create some similar styling for the second-level ("nested") bullet points. This time, you will set the bullet points to blue squares. For this, add these two rules:
.itemizedlist > ul.itemizedlist > li > .itemizedlist > ul.itemizedlist { list-style-type: square !important; } .itemizedlist > ul.itemizedlist > li > .itemizedlist > ul.itemizedlist > li::marker { color: #6495ed; font-size:1.2em; }
Here, you have used more specific selectors. The first rule targets the unordered list (
ul
) that is inside a listitem in a parent unordered list. The second rule targets the marker of list items in an unordered list that is inside alistitem
in a parent unordered list. -
Copy the rule and add it to your CSS.
Next: Style Numbered Lists.
Let's style the numbered lists (this applies to numbered lists, not procedures).
-
Use the Selector tool in the Browser Inspection Tool to select the number for a number list item.
Note
Make sure that you select a number for a list item in a number list. Do not select the number for a step in a procedure.
In the Elements section, you should see that the
::marker
pseudo element is highlighted in the ordered list structure. -
In the Styles, select the plus icon + to add a new style. By default it will be
::marker
but you should change it to:.orderedlist ::marker
Here, you have told the browser to only apply the style rule to
::marker
when it appears inside the "orderedlist" class. This is to make the selector more specific, so that the style does not apply to other lists that have the::marker
pseudo element, such as bullet lists. -
Enter the following styling for the
orderedlist ::marker
:.orderedlist ::marker { color: #a94442; }
This sets the color of the number in ordered lists to dark red.
-
Copy and paste the rule to your CSS.
Next: Style the Images.
You can use CSS to style images too. Here, you will learn how to add a border around an image, set the color of the border, and also add some padding so that there is space between the image and the border line.
-
Use the Selector tool in the Browser Inspection Tool to select the image in your content.
-
In the Styles, look for
img.materialboxed
. This is the rule that applies to all block images in Paligo content. -
Change the rule so that it has these properties:
img.materialboxed { border: 2px solid #ddd; max-width: 100%; height: auto; padding: 10px; }
This sets your block images to have:
-
2px thick, light gray solid border.
-
Maximum with of 100% of the viewport (display area).
-
Height that is set automatically. The browser sets the height automatically so that the image keeps its proportions in relation to the image width.
-
10px internal space (padding) between the image and the border line.
Note
This style will apply to all block images in your content. If you only want to style specific images, give the images a
role
attribute and value. Then in your CSS, use a selector to target the image byrole
name (class name). You will learn how to do this for a paragraph and table later in the tutorial and it works in the same way for images. -
-
Copy the rule and add it to your CSS.
Next: Style a Specific Paragraph.
When you made your sample topic, we asked you to give the second paragraph a role
attribute with the value indentbody. When you published, Paligo turned this value into a class name in the HTML. As it has a class name, you can use CSS to style the paragraph differently to other paragraphs.
-
Use the Selector tool in the Browser Inspection Tool to select the second paragraph in your sample topic.
-
In the Elements section, you should see that the paragraph has the class name in the HTML:
<p class="indentbody">
-
In the Styles section, select the plus icon + to add a new rule.
-
Edit the rule so that it applies a left margin indent to the text:
p.indentbody { margin-left: 2.5em; }
Here, you are targeting any paragraph element that has the class "indentbody".
The second paragraph appears indented in comparison to the first paragraph and the other content.
-
Copy the rule to your CSS file.
Next: Style the Table.
In Stage 1, you created a table and to give the table a role
attribute with the value: data-table. When you published the topic, Paligo created a div
in the HTML and gave it the class name "data-table". The div
is a container for your table and allows you to style the table differently to other tables.
You also gave the final cell in the table a class
attribute with the value "yellow-cell". This allows you to apply a style to that particular cell.
Let's customize your table:
-
Use the Selector tool in the Browser Inspection Tool to select the table in your sample topic.
-
Select the
thead
element (the table header). -
In the Styles , select the plus icon + to add a new rule.
-
Change the selector to:
.data-table > .table thead
With this selector, you are targeting the header (
thead
) of tables that are inside a parent element (in this case, adiv
) with the class name "data-table". The CSS you set inside this rule will not apply to the header of other tables. -
Set the background color and the text color for the header:
.data-table > .table thead { background-color: #9b9ba4; color: #ffffff; }
The header changes color to grey and any text in the header is white.
-
Copy the rule and paste it into your CSS.
-
Select the plus icon + to add another rule.
-
Change the selector and add these style properties:
.data-table > .table { border-style: solid; border-width: thin; border-color: darkgray; }
Again, this selector targets a table that is a child of an element that has the class "data-table". The styles set the table to have a solid, thin, dark gray border.
The border shows that the table has some extra space at the bottom. You will remove this in the next step.
-
Add the following style to rule you created in the previous step:
margin-bottom: 0px !important;
So your previous rule should now look like this:
.data-table > .table { border-style: solid; border-width: thin; border-color: darkgray; margin-bottom: 0px !important; }
This tells the browser to set the bottom margin to zero. The
!important
overrides the margin-bottom value that is set for all tables in another CSS. -
Copy the rule and paste it into your CSS.
-
Now let's give a background color to alternate rows in the table. Create this new rule:
.data-table > .table tbody tr:nth-child(2n) { background-color: ghostwhite; }
With this selector, you again target the table that is a child of the "data-table"
div
. This time, you also target the table body and thetr:nth-child (2n)
targets the even rows. You have set the background color of the rows to "ghost white".Back when you created your sample table, we asked you to give the last cell (
td
) a class attribute with the value "yellow-cell". Let's style that cell next. -
Use the browser's Select tool to select the last cell in the table.
-
In the Styles, select:
<td class="td yellow-cell">
-
Select the plus icon + to add a new rule and give the cell a yellow background:
.td.yellow-cell { background-color: #fdef20; }
-
Copy the rule and paste it into your CSS.
-
Save your CSS.
Next: Add a Logo.
Now let's upload your custom CSS to your Layout and republish.
-
Select the dotted menu ( ... ) for your sample publication.
-
Select Publish.
-
Select HTML5 and then choose your custom HTML5 Help Center Layout.
-
Select Publish Document.
Paligo publishes your HTML5 Help Center. The output downloads in the browser.
-
In the download, browse to out/index.html and then open the index.html file in your browser.
-
On the hub page, select your sample topic.
You should see that the HTML5 Help Center is using your custom CSS styles and your logo file.
You have now completed the HTML5 Help Center branding tutorial. You have learned how to:
-
Use the
role
attribute to give a class name to Paligo elements -
Use the
class
attribute to give a class name to rows or cells in a table -
Make styling changes to the sidebar, headings, paragraphs, lists, procedures, images, and tables.
-
Use the browser's Inspection tool to look at the underlying HTML, find class names, and try out CSS changes
-
Create a custom CSS file and upload it to a Layout
-
Change the logo for an HTML5 Help Center in the Layout settings.
You can use the same principles and techniques to customize other parts of your HTML5 Help Center.
Example 3. Completed CSS
The following code shows the complete CSS that you should have created during the tutorial. If your output does not look as expected, make sure your CSS matches the following CSS. Look carefully for missing characters and typing mistakes.
Also, check that you have applied the correct role
attribute and class
attribute values during the tutorial. Again, check for typing errors.
.bg-primary, .btn-primary, .pagination>.active>a, .pagination>.active>span, .pagination>.active>a:hover, .pagination>.active>span:hover, .pagination>.active>a:focus, .pagination>.active>span:focus, .site-sidebar, .portal-single-publication .publication-icon { background-color: #a94442; } /* The following rules change the heading and paragraphs */ .h2, h2 { font-size: 40px; color: #a94442; font-weight: 800; } .h3, h3 { font-size: 28px; color: #a94442; } .h4, h4 { font-size: 20px; color: #a94442; } /* Style the indented para */ p.indentbody { margin-left: 2.5em; } /* The following rule changes the background color of procedure numbers */ .theme1 .procedure > li::before { background-color: #a94442; } /* The following rule changes top-level bullet points to dark red squares */ .itemizedlist > ul.itemizedlist { list-style-type: square !important; } .itemizedlist ul.itemizedlist > li::marker { color: #a94442; font-size:1.2em; } /* The following rules change nested bullet list points to blue squares */ .itemizedlist > ul.itemizedlist > li > .itemizedlist > ul.itemizedlist { list-style-type: square !important; } .itemizedlist > ul.itemizedlist > li > .itemizedlist > ul.itemizedlist > li::marker { color: #6495ed; font-size:1.1em; } /* Style the image */ img.materialboxed { border: 2px solid #ddd; max-width: 100%; height: auto; padding: 10px; } /* Style the header of a table with class "data-table" */ .data-table > .table thead { background-color: #9b9ba4; color: white; } /* Style the borders of a table with class "data-table" */ .data-table > .table { border-style: solid; border-width: thin; border-color: darkgray; } /* Remove margin after table */ .data-table > .table { margin-bottom: 0px !important; } /* Target the even rows (2nd, 4th, 6th, etc.) inside the table with class "data-table" */ .data-table > .table tbody tr:nth-child(2n) { background-color: ghostwhite; } /* Style individual cell that has the class name "yellow-cell" */ .td.yellow-cell { background-color: #fdef20; }
Comments
0 comments
Article is closed for comments.