Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="page-wrapper">
  <nav id="navbar">
    <header>
      <img src="https://git.ruby-lang.org/cgit-css/ruby.png" alt="Ruby logo.">
      Ruby Documentation
    </header>
    <ul>
      <li><a href="#Introduction" class="nav-link">Introduction</a></li>
      <li><a href="#Features_of_Ruby" class="nav-link">Features of Ruby</a></li>
      <li><a href="#How_to_get_Ruby" class="nav-link">How to get Ruby</a></li>
      <li><a href="#Mailing_list" class="nav-link">Mailing List</a></li>
      <li><a href="#Seeing_everything_as_an_Object" class="nav-link">Seeing everything as an Object</a></li>
      <li><a href="#Ruby's_flexibility" class="nav-link">Ruby's flexibility</a></li>
      <li><a href="#Blocks:_a_Truly_Expressive_Feature" class="nav-link">Blocks: a Truly Expressive Feature</a></li>
      <li><a href="#Ruby_and_the_Mixin" class="nav-link">Ruby and the Mixin</a></li>
      <li><a href="#Ruby's_Visual_Appearance" class="nav-link">Ruby's Visual Appearance</a></li>
    </ul>
  </nav>
  <main id="main-doc">
    <section class="main-section" id="Introduction">
      <header>Introduction</header>
      <p>Ruby is an interpreted object-oriented programming language often used for web development. It also offers
        many scripting features to process plain text and serialized files, or manage system tasks. It has an elegant
        syntax that is natural to read and easy to write. It is simple, straightforward, and extensible.</p>
      <p><a href="https://www.ruby-lang.org/">The Ruby language home page</a></p>
    </section>

    <section class="main-section" id="Features_of_Ruby">
      <header>Features of Ruby</header>
      <ul>
        <li>Simple Syntax</li>
        <li>Normal Object-oriented Features (e.g. class, method calls)</li>
        <li>Advanced Object-oriented Features (e.g. mix-in, singleton-method)</li>
        <li>Operator Overloading</li>
        <li><a href="https://docs.ruby-lang.org/en/2.7.0/Exception.html"> Exception</a> Handling</li>
        <li>Iterators and Closures</li>
        <li>Garbage Collection</li>
        <li>Dynamic Loading of Object Files (on some architectures)</li>
        <li>Highly Portable (works on many Unix-like/POSIX compatible platforms as well as Windows, macOS, Haiku,
          etc.) cf. <a href="github.com/ruby/ruby/blob/master/doc/contributing.rdoc#platform-maintainers">github.com/ruby/ruby/blob/master/doc/contributing.rdoc#platform-maintainers</a>
        </li>
      </ul>
    </section>

    <section class="main-section" id="How_to_get_Ruby">
      <header>How to get Ruby</header>
      <p>
        For a complete list of ways to install Ruby, including using third-party tools like rvm, see:
      </p>
      <p>
        <a href=" www.ruby-lang.org/en/downloads/">www.ruby-lang.org/en/downloads/</a>
      </p>
    </section>

    <section class="main-section" id="Mailing_list">
      <header>Mailing List</header>
      <p>
        There is a mailing list to discuss Ruby. To subscribe to this list, please send the following phrase:
      </p>

      <p>
        <code>
          <strong>Subscribe</strong>
        </code>
      </p>

      <p>
        in the mail body (not subject) to the address <a href="mailto:ruby-talk-request@ruby-lang.org">ruby-talk-request@ruby-lang.org.</a>
      </p>
    </section>

    <section class="main-section" id="Seeing_everything_as_an_Object">
      <header>Seeing Everything as an Object</header>
      <p>In Ruby, everything is an object. Every bit of information and code can be given their own properties and
        actions. Object-oriented programming calls properties by the name instance variables and actions are known as
        methods. Ruby’s pure object-oriented approach is most commonly demonstrated by a bit of code which applies an
        action to a number.</p>

      <code>5.times { print "We *love* Ruby -- it's outrageous!" }</code>

      <p>In many languages, numbers and other primitive types are not objects. Ruby follows the influence of the
        Smalltalk language by giving methods and instance variables to all of its types. This eases one’s use of Ruby,
        since rules applying to objects apply to all of Ruby.</p>
    </section>

    <section class="main-section" id="Ruby's_flexibility">
      <header>Ruby's flexibility</header>
      <p>Ruby is seen as a flexible language, since it allows its users to freely alter its parts. Essential parts of
        Ruby can be removed or redefined, at will. Existing parts can be added upon. Ruby tries not to restrict the
        coder.</p>

      <p>For example, addition is performed with the plus (+) operator. But, if you’d rather use the readable word
        plus, you could add such a method to Ruby’s builtin Numeric class.</p>

      <code>
        class Numeric
        def plus(x)
        self.+(x)
        end
        end

        y = 5.plus 6
        # y is now equal to 11
      </code>

      <p>Ruby’s operators are syntactic sugar for methods. You can redefine them as well.</p>
    </section>

    <section class="main-section" id="Blocks:_a_Truly_Expressive_Feature">
      <header>Blocks: a Truly Expressive Feature</header>
      <p>Ruby’s block are also seen as a source of great flexibility. A programmer can attach a closure to any method,
        describing how that method should act. The closure is called a block and has become one of the most popular
        features for newcomers to Ruby from other imperative languages like PHP or Visual Basic.</p>

      <p>Blocks are inspired by functional languages. Matz said, “in Ruby closures, I wanted to respect the Lisp
        culture3.”</p>

      <code>
        search_engines =
        %w[Google Yahoo MSN].map do |engine|
        "http://www." + engine.downcase + ".com"
        end
      </code>

      <p>In the above code, the block is described inside the do ... end construct. The map method applies the block
        to the provided list of words. Many other methods in Ruby leave a hole open for a coder to write their own
        block to fill in the details of what that method should do.</p>
    </section>

    <section class="main-section" id="Ruby_and_the_Mixin">
      <header>Ruby and the Mixin</header>
      <p>Unlike many object-oriented languages, Ruby features single inheritance only, on purpose. But Ruby knows the
        concept of modules (called Categories in Objective-C). Modules are collections of methods.</p>

      <p>Classes can mixin a module and receive all its methods for free. For example, any class which implements the
        each method can mixin the Enumerable module, which adds a pile of methods that use each for looping.</p>

      <code>
        class MyArray
        include Enumerable
        end
      </code>

      <p>Generally, Rubyists see this as a much clearer way than multiple inheritance, which is complex and can be too
        restrictive.</p>
    </section>

    <section class="main-section" id="Ruby's_Visual_Appearance">
      <header>Ruby's Visual Appearance</header>
      <p>While Ruby often uses very limited punctuation and usually prefers English keywords, some punctuation is used
        to decorate Ruby. Ruby needs no variable declarations. It uses simple naming conventions to denote the scope
        of variables.</p>

      <code>
        var could be a local variable.
        @var is an instance variable.
        $var is a global variable.
      </code>

      <p>These sigils enhance readability by allowing the programmer to easily identify the roles of each variable. It
        also becomes unnecessary to use a tiresome <strong>.self</strong> prepended to every instance member.</p>
    </section>
  </main>
</div>

<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>

<!-- 

Hello Camper!

For now, the test suite only works in Chrome! Please read the README below in the JS Editor before beginning. Feel free to delete this message once you have read it. Good luck and Happy Coding! 

- The freeCodeCamp Team 

-->

              
            
!

CSS

              
                /* Generic Styling */

@import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;600&display=swap');

* {
    box-sizing: border-box;
    --black: rgba(0, 0, 0, 1);
    --dim-grey: rgba(105, 105, 105, 1);
    --faded-white: rgba(255, 255, 255, 1);
    --grey: rgba(211, 211, 211, 1);
    --light-grey: rgba(238, 238, 238, 0.8);
    --ruby-red: rgba(155, 17, 30, 1);
    --white: rgba(255, 255, 255, 1);
}

body {
    font-family: 'Roboto Slab', serif;
    font-size: 16px;
    background-color: var(--light-grey);
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

a {
    text-decoration: none;
    color: var(--ruby-red);
}

ul {
    list-style: none;
}

ul li::before {
    content: "\2022";
    color: var(--ruby-red);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

/* Specific Styling */

#page-wrapper {
  display: flex;
  justify-content: center;
}

header {
  font-size: 1.2rem;
  color: var(--ruby-red);
}

#navbar {
  width: 25%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: solid 2px var(--dim-grey);
  position: fixed;
  top: 0;
  left: 0;
}

#navbar header {
  display: flex;
  justify-content: space-between;
  text-align: center;
  padding-top: 20px;
}

#navbar img {
  height: 2rem;
  padding-right: 15px;
}

#navbar ul {
  width: 100%;
  height: 100%;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

#navbar ul li::before {
  content: none;
}

#navbar ul li {
  padding: 10px 15px;
  border-top: 1px solid var(--black);
}

#navbar .nav-link{
  font-size: 0.95rem;
  padding-left: 0.8rem;
}

#navbar .nav-link:hover {
  font-weight: 600;
}

#main-doc {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 75%;
  padding-left: 30px;
  margin-left: auto;
}

.main-section {
  padding: 1rem 0;
}

.main-section header {
  padding-bottom: 1rem;
}

.main-section ul {
  padding-left: 4rem;
}

.main-section code {
  display: inline-block;
  background-color: var(--grey);
  font-size: 0.9rem;
  padding: 1rem;
}

#Mailing_list p strong {
  line-height: 1rem;
  font-size: 1rem;
  color: var(--ruby-red);
}

@media (max-width: 1024px) {

  #navbar {
    display: flex;
    justify-content: space-around;
  }

  #navbar header {
    align-items: center;
    width: 70%;
    margin-right: 0.5rem;
    padding-top: 0.5rem;
    text-align: left;
    font-size: 1rem;
  }

  #navbar img {
  }
}

@media (max-width: 768px){
  #page-wrapper {
    position:relative;
    flex-direction: column;
    align-items: center;
  }

  #navbar, #main-doc {
    width: 100%;
  }

  #navbar {
    max-height: 20rem;
    position: relative;
  }

  #navbar header {
    justify-content: center;
    text-align: center;
    padding-top: 20px;
    font-size: 1.5rem;
  }

  #navbar img {
    height: 2rem;
    padding-right: 15px;
  }

  #main-doc {
    max-width: 100%;
    padding: 0;
    align-items: flex-start;
  }

  .main-section {
    margin: 0 1.5rem;
  }

  .main-section ul {
    width: auto;
    padding-left: 1.5rem;
    margin: 0;
  }

  .main-section ul li {
    margin: 0;
  }

}
              
            
!

JS

              
                // coded by @CharlesDeBarros
// eslint-disable-next-line no-unused-vars
const projectName = 'technical-docs-page';

// !! IMPORTANT README:

// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place. 

/***********
INSTRUCTIONS:
  - Select the project you would 
    like to complete from the dropdown 
    menu.
  - Click the "RUN TESTS" button to
    run the tests against the blank 
    pen.
  - Click the "TESTS" button to see 
    the individual test cases. 
    (should all be failing at first)
  - Start coding! As you fulfill each
    test case, you will see them go   
    from red to green.
  - As you start to build out your 
    project, when tests are failing, 
    you should get helpful errors 
    along the way!
    ************/

// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!

// Once you have read the above messages, you can delete all comments. 

              
            
!
999px

Console