Languages
[Edit]
EN

Dirask - how to format code in posts (JavaScript, HTML, CSS, React, SQL)

6 points
Created by:
Root-ssh
178290

This article presents basic rule for post code examples firmatting on Dirask.

CSS foramtting

Edit
  • 4 spaces indents for CSS code,
  • additional 4 space indent prefix if css nested in html code

e.g.

script.css file:

page.htm/page.html file with embedded css code:

HTML formatting

Edit
  • 2 spaces indents for HTML code,
  • html, head, body elements without indents,
  • double quotes ("") for attibute values

e.g.

page.htm/page.html file:

JavaScript formatting

Edit
  • 4 spaces indents for JavaScript code,
  • single quotes ('') or grave accent (``) for string values
    ('' for old JS, `` for modern JS only if needed)

e.g.

script.js file:

page.htm/page.html file with embedded JS code: 

React formatting

Edit
  • 4 spaces indents for JavaScript code,
  • 2 spaces indents for JSX code,
  • single quotes ('') or grave accent (``) for JavaScript string values
    ('' for old JS, `` for modern JS only if needed),
  • double quotes ("") for JSX elemnent attibute values

e.g.

App.jsx file:

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Dirask - content writing

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join