DEV Community

Kavei Sahai
Kavei Sahai

Posted on

I Built the ULTIMATE Educational Website from Scratch — Day 5

Yesterday, we worked on Periodic Properties, a specific article. Today, let's focus back on the actual site design and pages.

We'll create the organic chemistry page. We'll start by setting up the basic HTML structure, including placeholders for the interactive elements.

Hour 23: Building the Organic Chemistry Page

First, I created organic.html inside the \Chemistry folder. This is the basic structure:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Neuron IQ - Organic Chemistry</title>
    <meta name="description" content="Explore the fascinating world of organic chemistry with interactive articles, quizzes, and 3D molecule visualizations.">

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">

    <!-- Favicon -->
    <link rel="icon" type="image/png" href="/favicon.png">

    <!-- Stylesheets (Consider using a CSS preprocessor like Sass for better organization) -->
    <link rel="stylesheet" href="css/style-main.css">
    <link rel="stylesheet" href="css/style.css"> 
    <link rel="stylesheet" href="css/specific-chemistry.css">
</head>
<body>
    <header>
        <nav>
            <div class="logo">
                <a href="/index.html">Neuron IQ</a>
            </div>
            <button id="hamburger-btn" aria-label="Toggle navigation">
                <span></span>
                <span></span>
                <span></span>
            </button>
            <ul id="nav-menu">
                <li><a href="/index.html">Home</a></li>
                <li><a href="/subjects.html">Subjects</a></li>
                <li><a href="/about.html">About</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
        </nav>
    </header>

  <!-- Content goes here -->

    <footer>
        <div class="footer-content">
            <p>© 2025 Neuron IQ. All rights reserved.</p>
            <ul class="footer-links">
                <li><a href="/about.html">About Us</a></li>
                <li><a href="#">Contact Us</a></li>
                <li><a href="#">Privacy Policy</a></li>
                <li><a href="#">Terms of Use</a></li>
            </ul>
        </div>
    </footer>

    <!-- JavaScript (Load at the end of body for faster page load) -->
    <script src="https://www.lactame.com/lib/molgl/5.0.0/molgl.min.js"></script>
    <script src="js/scripts.js"></script> 
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

I've added basic structure, links to the main stylesheets, and CDN link to a 3D molecule viewer library molGL. I've also added a basic header and footer, consistent with our previous pages, and a button for hamburger menu.

Now, I'll add the main content area, divided into sections for articles, key topics, and an interactive molecule viewer.

<section class="specific-chemistry-page">
        <aside class="article-list">
            <h2>Organic Chemistry Articles</h2>
            <input type="text" id="article-search" placeholder="Search articles...">
            <ul id="article-links">
                <!-- Use JavaScript to dynamically populate this list based on search -->
                <li><a href="/Chemistry/organic/classification-and-nomenclature-of-organic-compounds.html">Classification and Nomenclature</a></li>
                <li><a href="#">Alkanes, Alkenes, Alkynes</a></li>
                <li><a href="#">Functional Groups</a></li>
                <!-- ... other articles ... -->
                <li><a href="#">Grignard Reagents</a></li>
            </ul>
        </aside>

        <main class="content-area">
            <div class="hero">
                <h1>Organic Chemistry</h1>
                <p>Explore the fascinating world of carbon compounds, their structure, properties, and reactions in an interactive way!</p>
                <button class="cta-button">Start Learning</button>
            </div>

            <div class="topic-list-grid">
                <h2>Key Topics</h2>
                <div class="topic-cards">
                    <!-- Example topic card -->
                    <div class="topic-card">
                        <a href="#">
                            <img src="images/hydrocarbons.jpg" alt="Hydrocarbons"> 
                            <h3>Hydrocarbons</h3>
                            <p>Learn about the simplest organic compounds.</p>
                        </a>
                    </div>
                    <div class="topic-card">
                        <a href="#">
                            <img src="images/functional.jpg" alt="Functional Groups"> 
                            <h3>Functional Groups</h3>
                            <p>Discover the key to organic reactivity.</p>
                        </a>
                    </div>

                    <div class="topic-card">
                        <a href="#">
                            <img src="images/alcohol.jpg" alt="Alcohols, Aldehydes, Ketones"> 
                            <h3>Alcohols, Aldehydes, Ketones</h3>
                            <p>Oxygen-containing functional groups and their properties.</p>
                        </a>
                    </div>

                    <div class="topic-card">
                        <a href="#">
                            <img src="images/reaction.jpg" alt="Reactions of Alkanes, Alkenes and Alkynes"> 
                            <h3>Reactions of Alkanes, Alkenes and Alkynes</h3>
                            <p>Explore addition, substitution, and other key reactions.</p>
                        </a>
                    </div>

                    <div class="topic-card">
                        <a href="#">
                            <img src="images/acid.jpg" alt="Carboxylic Acids and Esters"> 
<h3>Carboxylic Acids and Esters</h3>
                            <p>Acidity, esterification, and important derivatives.</p>
                        </a>
                    </div>

                    <div class="topic-card">
                        <a href="#">
                            <img src="images/amines.jpg" alt="Amines and Amides"> 
                            <h3>Amines and Amides</h3>
                            <p>Nitrogen-containing compounds and their basicity.</p>
                        </a>
                    </div>

                    <div class="topic-card">
                        <a href="#">
                            <img src="images/stereochemistry.jpg" alt="Stereochemistry"> 
                            <h3>Stereochemistry</h3>
                            <p>The 3D arrangement of atoms and its impact.</p>
                        </a>
                    </div>

                    <div class="topic-card">
                        <a href="#">
                            <img src="images/spectroscopy.jpg" alt="Spectroscopy"> 
                            <h3>Spectroscopy</h3>
                            <p>Techniques to identify and analyze organic compounds.</p>
                        </a>
                    </div>
                    <!-- ... more topic cards ... -->
                </div>
            </div>

            <!-- Interactive 3D Molecule Viewer (Example using MolGL) -->
            <div class="molecule-viewer">
                <h2>Interactive Molecule Viewer</h2>
                <div id="mol-container"></div>
                <p>Select a molecule: 
                    <select id="molecule-select">
                        <option value="methane">Methane</option>
                        <option value="ethanol">Ethanol</option>
                        <option value="benzene">Benzene</option>
                    </select>
                </p>
            </div>
        </main>
    </section>
Enter fullscreen mode Exit fullscreen mode

This code adds a three-column layout. The left column will house the article list with a search bar. The middle column will have a hero section with a call-to-action button and a grid of topic cards with images. Finally, the right column will feature the interactive 3D molecule viewer.

I've also added placeholders for images within the topic cards (images/hydrocarbons.jpg, etc.). We'll need to replace these with actual images later.

Hour 24: Adding JavaScript for Interactivity

Now, let's add some basic JavaScript to handle the hamburger menu, the article search functionality, and the 3D molecule viewer. I'll add the following inside the <script> tag at the end of the body:

        // Hamburger Menu Toggle
const hamburgerBtn = document.getElementById('hamburger-btn');
const navMenu = document.getElementById('nav-menu');

hamburgerBtn.addEventListener('click', () => {
  navMenu.classList.toggle('show'); 
});

// Article Search Functionality (Basic Example)
const articleSearch = document.getElementById('article-search');
const articleLinks = document.getElementById('article-links').querySelectorAll('a');

articleSearch.addEventListener('input', () => {
  const searchTerm = articleSearch.value.toLowerCase();

  articleLinks.forEach(link => {
    const linkText = link.textContent.toLowerCase();
    if (linkText.includes(searchTerm)) {
      link.style.display = 'block';
    } else {
      link.style.display = 'none';
    }
  });
});

// 3D Molecule Viewer (MolGL Example)
const molContainer = document.getElementById('mol-container');
const moleculeSelect = document.getElementById('molecule-select');

// Initialize MolGL viewer 
let viewer = new MolGL({
  container: molContainer,
  style: {
    stick: {},
    sphere: { scale: 0.3 }
  }
});

// Load a default molecule
viewer.load('pdb:1crn'); // Example: Load a PDB structure

// Change molecule on selection
moleculeSelect.addEventListener('change', () => {
  const selectedMolecule = moleculeSelect.value;
  // We'll need to map molecule names to appropriate data sources (e.g., PDB IDs, SDF files)
  if (selectedMolecule === 'methane') {
    viewer.load('sdf:./molecules/methane.sdf'); // Example: Load from an SDF file
  } else if (selectedMolecule === 'ethanol') {
    viewer.load('pdb:1etn');
  } else if (selectedMolecule === 'benzene') {
    viewer.load('sdf:./molecules/benzene.sdf');
  }
});
Enter fullscreen mode Exit fullscreen mode

Here's what this JavaScript does:

  1. Hamburger Menu Toggle: Adds an event listener to the hamburger button to toggle the show class on the navigation menu, making it visible or hidden on small screens.
  2. Article Search: Implements a simple search functionality that filters the article links based on the user's input in the search bar.
  3. 3D Molecule Viewer:
    • Initializes a MolGL viewer instance within the mol-container element.
    • Loads a default molecule (crambin protein, 1crn) in PDB format from external link.
    • Adds an event listener to the molecule selection dropdown to load different molecules when the user makes a selection.
    • Uses placeholder molecule data sources (./molecules/methane.sdf, etc.). We'll need to provide actual molecule data in the correct format (SDF, PDB, etc.) and map the molecule names accordingly.

Live page is over here, if you want to see:

Organic Chemistry - NeuronIQ

Hour 25: Creating the Inorganic Chemistry Page

Let's create a new page for inorganic chemistry, similar in structure to the organic chemistry page.

First, I created inorganic.html inside the \Chemistry folder with the following basic structure:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Neuron IQ - Inorganic Chemistry</title>
    <link rel="stylesheet" href="style.css">
       <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
     <link rel="stylesheet" href="style-main.css">
      <link rel="stylesheet" href="specific-chemistry.css">
</head>
<body>
    <header>
        <nav>
            <div class="logo">Neuron IQ</div>
            <ul>
                <li><a href="/index.html">Home</a></li>
                 <li><a href="/subjects.html">Subjects</a></li>
                <li><a href="/about.html">About</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
        </nav>
    </header>

    <section class="specific-chemistry-page">
        <aside class="article-list">
             <h2>Inorganic Chemistry Articles</h2>
            <ul>
                <li><a href="#">Introduction to Coordination Chemistry</a></li>
                <li><a href="#">The Structure of Metal Complexes</a></li>
                <li><a href="#">Bonding in Inorganic Compounds</a></li>
                <li><a href="#">Transition Metal Chemistry</a></li>
                 <li><a href="#">Main Group Elements</a></li>
                   <li><a href="#">Acid-Base Reactions</a></li>
                   <li><a href="#">Solid State Chemistry</a></li>
                      <li><a href="#">Bioinorganic Chemistry</a></li>
                       <li><a href="#">Organometallic Chemistry</a></li>
                           <li><a href="#">Catalysis</a></li>
            </ul>
        </aside>

       <main class="content-area">
             <h1>Inorganic Chemistry</h1>
            <p>Dive into the study of elements other than carbon, their compounds, and their properties.</p>
             <div class="topic-list-grid">
                 <h2>Key Topics</h2>
                  <ul>
                     <li><a href="#">Coordination Compounds</a></li>
                     <li><a href="#">Transition Metals</a></li>
                     <li><a href="#">Main Group Elements</a></li>
                     <li><a href="#">Solid State Structure</a></li>
                      <li><a href="#">Acid-Base Chemistry</a></li>
                     <li><a href="#">Organometallic Chemistry</a></li>
                      <li><a href="#">Bonding in Inorganic Compounds</a></li>
                      <li><a href="#">Applications of Inorganic Compounds</a></li>

                     </ul>
             </div>

        </main>

    </section>

  <footer>
          <p>© 2025 Neuron IQ. All rights reserved.</p>
        <ul>
            <li><a href="/about.html">About Us</a></li>
            <li><a href="#">Contact Us</a></li>
            <li><a href="#">Privacy Policy</a></li>
            <li><a href="#">Terms of Use</a></li>
        </ul>
    </footer>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

This code sets up the HTML for the page with:

  • A basic header with navigation links.
  • An aside element for the article list.
  • A main content area with a heading, introductory text, and a grid for key topics.
  • Placeholder links for articles and topics.
  • A footer.

We are using style.css, style-main.css and specific-chemistry.css for the styling.

Next, I added some content to the page:

<section class="specific-chemistry-page">
    <aside class="article-list">
         <h2>Inorganic Chemistry Articles</h2>
        <input type="text" id="article-search" placeholder="Search articles...">
        <ul id="article-links">
            <li><a href="/Chemistry/inorganic/introduction-to-coordination-chemistry.html">Introduction to Coordination Chemistry</a></li>
            <li><a href="/Chemistry/inorganic/the-structure-of-metal-complexes.html">The Structure of Metal Complexes</a></li>
            <li><a href="/Chemistry/inorganic/bonding-in-inorganic-compounds.html">Bonding in Inorganic Compounds</a></li>
            <!-- ... other articles ... -->
        </ul>
    </aside>

    <main class="content-area">
         <h1>Inorganic Chemistry</h1>
        <p>Dive into the study of elements other than carbon, their compounds, and their properties.</p>
         <div class="topic-list-grid">
             <h2>Key Topics</h2>
              <ul>
                 <li><a href="#">Coordination Compounds</a></li>
                 <li><a href="#">Transition Metals</a></li>
                 <li><a href="#">Main Group Elements</a></li>
                 <li><a href="#">Solid State Structure</a></li>
                  <li><a href="#">Acid-Base Chemistry</a></li>
                 <li><a href="#">Organometallic Chemistry</a></li>
                  <li><a href="#">Bonding in Inorganic Compounds</a></li>
                  <li><a href="#">Applications of Inorganic Compounds</a></li>
                 </ul>
         </div>
    </main>
</section>
Enter fullscreen mode Exit fullscreen mode

I also added a search bar and some links, that we will add later.

Hour 26: Adding JavaScript for Search Functionality

Since we used a similar structure to the organic chemistry page, I copied over the JavaScript code for the hamburger menu and the article search functionality from organic.html to this inorganic chemistry page, removing the 3D molecule viewer part.

// Hamburger Menu Toggle
const hamburgerBtn = document.getElementById('hamburger-btn');
const navMenu = document.getElementById('nav-menu');

hamburgerBtn.addEventListener('click', () => {
  navMenu.classList.toggle('show'); 
});

// Article Search Functionality (Basic Example)
const articleSearch = document.getElementById('article-search');
const articleLinks = document.getElementById('article-links').querySelectorAll('a');

articleSearch.addEventListener('input', () => {
  const searchTerm = articleSearch.value.toLowerCase();

  articleLinks.forEach(link => {
    const linkText = link.textContent.toLowerCase();
    if (linkText.includes(searchTerm)) {
      link.style.display = 'block';
    } else {
      link.style.display = 'none';
    }
  });
});
Enter fullscreen mode Exit fullscreen mode

I had to adjust the selectors to match the IDs used in this page. This script now handles the basic hamburger menu toggle and article search filtering.

We now have a basic inorganic.html page with a similar structure to the organic chemistry page. We can further enhance it by:

  1. Adding Content:
    • Write the actual articles for the topics listed.
    • Add images or diagrams to the topic grid.
  2. Styling:
    • Improve the visual presentation with CSS.
    • Ensure responsiveness for different screen sizes.
  3. More Interactivity:
    • Add quizzes or interactive diagrams as needed.
  4. Navigation:
    • Implement a more robust navigation system if the site becomes more complex, as the current one is quite basic

Since our main focus for today was setting up the structure and basic functionality, we can consider these enhancements in the next steps. We can also improve on this by adding more relevant content, and working on the responsiveness of the page.

Top comments (0)