{% set title = "Using HTML, JavaScript, CSS" %} {% set filename = "usingHtmlJavaScriptCss" %} {{ title }}
title: "User Guide: {{ title }}" layout: userGuide.md pageNav: 2 [_User Guide → {{ title }}_]({{ filename }}.html)A MarkBind source file can contain a mixture of HTML, JavaScript, and CSS as a normal web page would.
==Text within HTML tags are considered plain text unless the text is preceded by a blank line,== in which case the text is parsed as Markdown text.
{{ icon_example }} Here is an example of how text within an HTML tag is parsed as Markdown when preceded by a blank line.
htmlWith preceding blank line: Apples Bananas Cherries
Alternatively, you can use <markdown> (for block Markdown elements such as headings) or <md> (for inline Markdown elements such as bold/italic text) tags to indicate the text should be treated as Markdown.
{{ icon_example }} Here is an example of how text within an HTML tag can be treated as Markdown using <markdown>/<md> tags.
External JavaScript libraries can be included in MarkBind to add a wide range of features and functionalities. One such use case is to add a charting library for data visualization.
Popular chart libraries such as Chart.js and Apache ECharts can be used in MarkBind to create beautiful charts, similar to how they are used in any HTML web page. The details of how to use these libraries are beyond the scope of this section, but you can find more information on their websites. In general, you will perform these 3 steps:
- Import the library via a CDN or locally.
- Specify a target HTML element to render the chart.
- Initialize the chart with the data and options.
As mentioned in the above section, you should not leave any blank lines within HTML elements to prevent MarkBind from parsing the contents as Markdown instead of code/text.
{{ icon_example }} Here is an example of how to use Chart.js to create a pie chart.
HTML <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.1/chart.min.js"></script>{{ icon_example }} Here is an example of how to use Apache ECharts to create a bar chart.
HTML <script src="https://cdn.jsdelivr.net/npm/echarts@5.3.2/dist/echarts.js"></script> <script type="text/javascript"> // Initialize the echarts instance based on the prepared DOM var eChart = echarts.init(document.getElementById('echart')); // Specify the configuration items and data for the chart var option = { title: { text: 'ECharts Getting Started' }, xAxis: { data: ['Shirts', 'Cardigans', 'Chiffons'] }, tooltip: {}, yAxis: {}, series: [ { name: 'sales', type: 'bar', data: [5, 20, 36] } ] }; // Display the chart using the configuration items and data just specified. eChart.setOption(option); </script>You can apply your own custom CSS styles to customize how your site looks.
There are two common ways to add custom CSS in MarkBind:
To apply styles across your whole site, create a file called styles.css
(or similar) in the root of your site (same level as index.md), and then
add it to your site.json under the head array like so:
{
"head": [
{
"tagName": "link",
"attributes": {
"rel": "stylesheet",
"href": "/styles.css"
}
}
]
}{% from "njk/common.njk" import previous_next %} {{ previous_next('components/advanced', 'tweakingThePageStructure') }}