Give Every Element an Address: Building LLM-Editable HTML Pages

●1 ●4
calendar_today • schedule3 min read

By Zahi Raifer

If you plan to let a language model edit HTML after it's generated, the most important decision happens before the first edit. It happens at build time, when you decide what the page will look like to the code that edits it later.

At Orivox, an AI website builder I work on that is designed for Hebrew and other right-to-left languages, we learned this the practical way. Below are the four build-time rules we apply to every generated page, and why each one makes later AI edits smaller, safer and easier to verify.

The setup

A new site starts from a short conversation: what the business does, the main call to action, a phone or WhatsApp number. That brief goes to Gemini with a detailed build prompt, and the model returns a complete page of HTML and Tailwind in one pass.

That output is a good draft, but it's not yet something you can edit safely. Python takes it from there and handles everything that has to be exact.

Rule 1: every element gets an address

Each element receives a short, unique data-ai-id attribute. Later, every edit points at elements by that id, using a selector like [data-ai-id='a0f0'].

Why not use CSS classes or the element's position in the tree? Classes are shared and change when styling changes. Positions shift as soon as something is inserted. An id that's assigned once and never reused gives the model and the code an unambiguous way to say "this one."

Here is a simplified sketch of the idea with BeautifulSoup (illustrative, not our production code):

import secrets
from bs4 import BeautifulSoup

def assign_ids(html: str) -> str:
    soup = BeautifulSoup(html, "html.parser")
    used = set()
    for el in soup.find_all(True):
        if el.has_attr("data-ai-id"):
            used.add(el["data-ai-id"])
            continue
        new_id = secrets.token_hex(2)
        while new_id in used:
            new_id = secrets.token_hex(2)
        el["data-ai-id"] = new_id
        used.add(new_id)
    return str(soup)

Once ids exist, an edit is a short list such as "add a class to a0f0, set the text of b31c." Our grammar has 14 verbs (set_text, replace_html, insert_before, insert_after, append_html, prepend_html, remove, set_attr, remove_attr, add_class, remove_class, move_before, move_after, move_to_page), and every one of them targets an id. In our benchmarks, the planner's output had a median of just 141 tokens per turn, because addressing is cheap when the addresses already exist.

Rule 2: shared parts stay shared

The header, footer and head scripts are stored as partials with include markers instead of being copied into every page. When the planner works on a page, the editing service assembles it in memory with the partials inlined, so the model sees the full page. When a change lands in the footer, it's written once and reaches every page.

Without this rule, "change the phone number in the footer" becomes N edits across N pages, and N chances to miss one.

Rule 3: images are served at exact sizes

Every image goes through our own resizing service, and each page registers the precise sizes it needs. Because those addresses are structured, a save-time check can re-validate every image address on every save, so an edit can't silently leave an image loading at the wrong size.

Rule 4: language and direction live at the root

The root element declares lang and dir, and the page loads a font with full Hebrew coverage. Putting direction at the root, rather than patching individual blocks, means an edit that inserts a new section inherits correct right-to-left behaviour automatically. For a Hebrew-first product this isn't cosmetic. It decides whether every later edit renders correctly.

And one rule for history

The first edit commits the original site as a baseline in the project's Git repository, and every turn after that is its own commit. Combined with stable ids, this gives you precise diffs. You can see exactly which addressed elements changed in each turn and restore any earlier version.

Takeaways

  • Decide on addressability at build time. Retrofitting ids onto pages that are already being edited is much harder.
  • Keep repeated regions as single sources, and inline them only when assembling for the model.
  • Make anything a check needs (image sizes, direction, protected elements) explicit in the markup.
  • Commit a baseline before the first AI edit.

If you want to see what this produces on real pages, Orivox has a free plan for one site at orivox.org.


Zahi Raifer is a software developer with 23 years of experience in AI development, Python, .NET and databases, and the founder of Orivox.

Want more #python deep dives?

Join 6,182+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

1 Comment

0 votes

More Posts

Attention-Free Score: How Domain Reports Show Which Pages Need Work

ApogeeWatcherverified - Sep 1

Stop trusting verdicts your policy no longer supports

VEACESLAV - Dec 1

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

Stop Turning Every REST Endpoint into an MCP Tool: A Better Approach to AI Tool Design

zeekwrites - Nov 30

Free SEO Tools Every Small Business Should Use (2026) | FloxoLab

floxolab - Oct 20
chevron_left
133 Points • 5 Badges
1Posts
0Comments

Related Jobs

View all jobs →

Commenters (This Week)

28 comments
27 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!