lokesh144 / HTMLer

A Minimal HTML Parser and Renderer written in CPP.

Repository from Github https://github.comlokesh144/HTMLerRepository from Github https://github.comlokesh144/HTMLer

🧾 C++ HTML & CSS Parser & Renderer

This project is a C++-based HTML and CSS parser and renderer, developed as a course project. It parses a static HTML file and applies styles defined in a CSS file. The output is rendered in a graphical window using SDL2 and SDL_ttf libraries, simulating a basic browser rendering engine.


πŸ“Œ Features Implemented

This project supports parsing and rendering of the following:

βœ… HTML Tags

  • <html>, <head>, <body>
  • <h1>, <h2> (Headings)
  • <div> (Blocks/Sections)
  • <p> (Paragraphs)

βœ… CSS Features

  • color, background-color
  • margin, padding
  • font-size
  • hover effects:
    • Text color change
    • Background color change

🎯 Project Capabilities

This parser and renderer can handle:

  • Nested HTML structure
  • Class-based CSS styling (e.g., .child1, .parent1, etc.)
  • Inline layout simulation
  • Hover effect simulation
  • Simplified box model (margin + padding)
  • Consistent color rendering using SDL

πŸ›  How to Run

πŸ” Clone the repository

git clone https://github.com/your-username/cpp-html-css-renderer.git
cd cpp-html-css-renderer

πŸ’» Open in Visual Studio

  1. Open the .sln file in Visual Studio.
  2. Set the project as startup.
  3. Configure Environment Variables for SDL:
    • Add paths to SDL2 and SDL_ttf headers and libraries in:
      • Project Properties > VC++ Directories
      • Project Properties > Linker > Additional Dependencies
  4. Build and Run.

Make sure the sample HTML (index.html) and CSS (style.css) files are in the correct directory.


πŸ–Ό Rendering Previews

βœ” Browser View

Browser

βœ” HTMLer Output

HTMlLer


πŸ“š Supported CSS Properties

Property Supported
margin βœ…
padding βœ…
color βœ…
background-color βœ…
font-size βœ…
:hover effects βœ…

πŸ”§ Future Improvements

  • Add support for more HTML tags like <ul>, <li>, <a>, <img>
  • Advanced CSS features like border, display, flex, etc.
  • JavaScript support for basic interactivity
  • Improved rendering engine and layout management

πŸ“¦ Dependencies


🧠 Learning Objectives

  • Understand parsing of structured text (HTML & CSS)
  • Explore how rendering engines interpret code
  • Develop low-level graphical rendering using C++
  • Improve code organization and architecture for interpreters

πŸ“ƒ License

This project is intended for educational purposes only. All content is Β© 2025.


Feel free to fork and expand the renderer to support more tags, styling rules, and interactions!

About

A Minimal HTML Parser and Renderer written in CPP.


Languages

Language:C 91.4%Language:C++ 6.8%Language:CMake 0.8%Language:Objective-C 0.5%Language:HTML 0.4%Language:CSS 0.1%