Entrance Chat Gallery Search Everyone Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
June 28, 2025 - @27.37 (what is this?)
Activity rating: Four Stars Posts & Arts: 62/1k.beats Unread Topics | Unread Replies | My Stuff | Random Topic | Recent Posts Start New Topic  Submit Art
News: :skull: Websites are like whispers in the night  :skull: Super News: Upload a banner!

+  MelonLand Forum
|-+  World Wild Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  Digital Garden Topography in Basic HTML/CSS


« previous next »
Pages: [1] Print
Author Topic: Digital Garden Topography in Basic HTML/CSS  (Read 548 times)
thearistocats
Casual Poster ⚓︎
*


⛺︎ My Room
RSS: RSS

View Profile WWW

Joined 2025!
« on: May 24, 2025 @113.44 »

Static site digital gardeners, I need your advice!

I am just in the beginning stages of creating a digital garden on my page. I don't have anything live for it yet because I can't seem to conceptualize how to have a garden-like topography with just basic HTML/CSS. I'd like to have some kind of tagging system, but I don't really know where to start with that. It feels like there should be a way to give elements in HTML a particular class (like a tag) and then be able to filter/view only certain tags, but I have no idea if this is possible with just HTML and CSS. Does anyone have any recommendations on what I should be looking for? I am still an HTML and CSS novice, and I can't really figure out how to search for this and find anything usable.

Thanks!
« Last Edit: May 24, 2025 @843.15 by thearistocats » Logged

find me on lovethea.net, your premier source for all thea related news

she/it
edea
Casual Poster ⚓︎
*


⛺︎ My Room
Itch.io: My Games

View Profile WWW

Joined 2025!
« Reply #1 on: May 24, 2025 @687.65 »

Heya, I don't know if this is possible using PURELY HTML/CSS, but it's VERY possible once you mix in some basic Javascript (which is usable pretty much anywhere you can use HTML/CSS, even static site hosts)!
You can do this with some checkboxes and a button that triggers a JS function. Consider this example:
Code
<div id="checkbox-container">
  <label> 
    Show Blue Elements
    <input type="checkbox" id="blue-elem-check" name="blue-elem-check" value="Blue" checked>
  </label>
  <label> 
    Show Red Elements
    <input type="checkbox" id="red-elem-check" name="red-elem-check" value="Red" checked>
   </label>
   <label> 
     Show Yellow Elements
     <input type="checkbox" id="yellow-elem-check" name="yellow-elem-check" value="Yellow" checked>
   </label>
   <button type="button" onclick="colorFilter()">Filter</button>
</div>
<div class="blue"></div>
<div class="yellow"></div>
<div class="red"></div>
<div class="blue"></div>
<div class="yellow"></div>
<div class="red"></div>
And this CSS to style it:
Code
#checkbox-container {
  display: flex;
  flex-direction: column;
  margin-bottom: 50px;
}
    		
.checkbox-container label {
  padding-bottom: 5px;
}
    		
.checkbox-container button {
  width: 80px;
}
    		
.blue, .red, .yellow {
  width: 50px;
  aspect-ratio: 1 / 1;
}
    		
.blue {
  background-color: blue;
}
    		
.red {
  background-color: red;
}
    		
.yellow {
  background-color: yellow;
}
With this, you'll end up with a page looking like this, with checkboxes for each type of element, then the elements themselves.

When you click the Filter button, it will call a javascript method "colorFilter()". We can write that method as such:
Code
function colorFilter() {
  var showBlue = document.getElementById("blue-elem-check").checked;
  var showRed = document.getElementById("red-elem-check").checked;
  var showYellow = document.getElementById("yellow-elem-check").checked;
				
  var blueElements = document.getElementsByClassName("blue");
  var redElements = document.getElementsByClassName("red");
  var yellowElements = document.getElementsByClassName("yellow");
				
  for (var i = 0; i < blueElements.length; i++) {
    var currentElement = blueElements[i];
    if (showBlue == true) {
      currentElement.style.visibility = "visible";
    }
    else {
      currentElement.style.visibility = "hidden";
    }
  };
  ...[Repeat for loop for the other colors, changing the variable names for each class you have]				
}
With this, by checking and unchecking each type of element (denoted by their html class attribute) then hitting the Filter button, you can toggle visibility for any number of categories. You can then go on to style this and add CSS animations if you want the hiding and showing to be a bit prettier.
If you wanna mess with it, here's a JSFiddle you can use to test it and try other styling or adding images: https://jsfiddle.net/r4nd2zhy/1/
Logged






thearistocats
Casual Poster ⚓︎
*


⛺︎ My Room
RSS: RSS

View Profile WWW

Joined 2025!
« Reply #2 on: May 28, 2025 @118.09 »

Thank you very much for such an in-depth answer! I tinkered with it a bit and got something pretty close working on a local test site. Very much appreciated!
Logged

find me on lovethea.net, your premier source for all thea related news

she/it
Pages: [1] Print 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | ~ Send Feedback ~ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi