[How to] Format code in posts

Codecademy Discuss posts are parsed with Markdown. Markdown allows for easy formatting of code and text, and strips HTML out of posts by default to prevent security risks. This will show you how to format your code so it shows up.

Summary

To format code so itโ€™s visible, either wrap it in single backticks (``` ``) for a small amount of code, or triple backticks on an otherwise blank line before and after for a large amount of code.

Details

Inline code

To indicate a small span of code, wrap it in backticks (`). For example:

How do I use the `console.log()` function?

would produce:

How do I use the console.log() function?

Code Blocks

Toolbar Icon
Using Preformatted Text icon on the toolbar


This will automatically create a code block which you can paste your code in.
capture_r
Or select your code and then press the icon.

Manually

To indicate a code block, either wrap the entire block in three backticks:

```
<!DOCTYPE html>
<html>
  <head>
    <!-- metadata and external resources-->
  </head>
  
  <body>
    <!-- page content -->
  </body>
</html>
```

Or, (2) you can indent the code with four (4) spaces:

    <!DOCTYPE html>
    <html>
      <head>
        <!-- metadata and external resources-->
      </head>
      
      <body>
        <!-- page content -->
      </body>
    </html>

The first produces:

<!DOCTYPE html>
<html>
  <head>
    <!-- metadata and external resources-->
  </head>
  
  <body>
    <!-- page content -->
  </body>
</html>

The second produces:

<!DOCTYPE html>
<html>
  <head>
    <!-- metadata and external resources-->
  </head>
  
  <body>
    <!-- page content -->
  </body>
</html>

For more information on Markdown Formatting, visit daringfireball.net or commonmark.org.

14 Likes
7. Adding images
Saving data lesson 4
How can i change the style of color
LOOPS Same Values
How to Use the Codecademy Community Forums
Someone please let me know where is the error in my code
FAQ: Semantic HTML - Audio and Attributes
Task Board Project
Position:fixed; is making my navigation bar disappear
Noob coding question
Need plain simple straight forward simple to understand formatting instructions
Can anyone give me some tips on making this liltle program smaller
<!DOCTYPE html> error
Am stocked at 5/13 - HELP MOVED TO 8/13
6. Is this a trick or something
Why Does This Print Statement Not Execute?
Meal Maker undefined and NaN
[Challenge] Anagrams
How to ask a good question
How can I access a dictionary key value inside of a loop?
JavaScript Interactive Websites - Chore Door Project
Problem Solving
Need help please, can't make return or variables
What's JavaScript Thinking Here?
Grade Analyzer: methods for the lowest or highest class grade
Python, how to replace a text from a file between two tags?
Parts of my code, where I have comments, go bold
Reduce method - Bild a Library
FAQ: Learn HTML - Intro to HTML - HTML Structure
.friend class border
Bug in HTML Basic Session II: 8. Fonts
Is anyone here? I need help. Is this an internal error? Seek to save
CSS: An Overwiev, point 9
For the Record
4. The sum of scores
Dictionaries.update({key:value}) option
10. Divs & classes - cannot reset
Social Network - paragraph doesn't work
How do you add a link in 6/15? i'm terribly stuck
7 More Link Attributes
<!DOCTYPE html> <html> </html>
Return original
Self closing tags part 2/18
Html & css Lesson 13 HELP!
Stuck in Hello Sass nesting 5/9
Is the Final / Finished code available for comparison?!
In lesson 7/13 photo is not opening and after click on run it show Did you use second image URL?
My title never appears
How do I format my code?
CSS Please help!
12. Check yourself before you Wreck yourself. HELP!
Exercise 5 how do you do it?
CSS: An Overview A font of knowledge I NEED HELP CHANGING THE HEADERS
Link coding
Stuck on 23
Background won't change to brown
Floating left and right
8: Part of the Whole. What am I doing wrong?
Can someone help me with adding the Unordered list?
Name = raw_input("What is your name?") quest = raw_input("What is your quest?") color = raw_input("What is your favorite color?") print "Ah, so your name is %s, your quest is %sand your favorite color is %s" %(name, quest, color);what wrong in this code?
[Challenge] Unique Characters in a String
[Challenge] The Classic FizzBuzz Challenge
[Challenge] Anagram Detector
A bug about: Exercise 5-The CSS Setup (Learn HTML&CSS)
[Challenge] Reverse Words
Help with CSS for Course assingment : Nav section background color not showing up
Image attributes for visually impaired
[Challenge] Egg Dropper ๐Ÿฅš
[Challenge] Change Please
[Challenge] Comparative Weights โš–๏ธ
[Challenge] Print Times Tables ๐Ÿ–จโŽ
JavaScript error: Uncaught SyntaxError: Unexpected end of input
Return II , followed instructions to the dot, but still having problems
[Challenge] Stairmaster ๐Ÿ“ถ
Font weight bold
6/7 code won't run
Link to destination
What;s wrong with my code?
Divid and conquer
Functions > Return || (6/7)
[Challenge] Calculate Max, Min, and Averages ๐Ÿƒ
Switch
[Challenge] Fibonacci Finder
Error in Functions! - Pizza getTotal
Comma Separated List
Common elements Exercise 11/15
Could somebody hepl me pezl
7/13 this.props.7/13 this.props. Why do we have to include function in class definition, what happens if a function is outside of a class passed as props to other component?
[Challenge] Flatten an Array โ™ญ
Essential Information on Code Challenges
[Challenge] Palindrome Detector
[Challenge] Find the Missing Number ๐Ÿ”Ž
8.images- image not appearing-help! :/
[Challenge] Palindrome Detector
HTML Basic Lesson 15/17
"expected [Function" error
[Challenge] Top Score Sorter
Problem with prompt task in Javascript lesson
Set up the albums#show controller action in the Bass Music project
CSS font-weight property
26. link and text-decoration
Javascript, 'for loops inside for loops '
17.review functions NEED HELP
[Challenge] Select a number, any number
Else if statements
What's the difference?
How is this supposed to look with one parameter orderCount
15. Same Page. unordered lists
Pygame help
[Challenge] Product of Everything Else
PLS help with my simple asssignment, a guessing game in python
PLS help with my simple asssignment, a guessing game in python
5/7 for loops inside of for loops
FAQ: Learn Bash Scripting - Review
ArrayList String problem
Does anyone know why in the constructor (self.full = name + version ) why name + version doesn't have to be self.name + self.version?
Rock, Paper & Scissors Project - Error message
Advanced Python Code Challenges : Control Flow
Sleep Debt Calculator โ€“ My code works, but it is saying undefined
If elif for Grade Convertor