The desired result from this code is for the lines to auto indent, based on the previous sibling element. Right now the best I can do is hardcoded CSS classes, which I've included in the below example.
If possible, I'd like to have the text indent out for the open class, and indent down for the close class. Though really, anything would be better than what I currently have. I'm hoping I can replicate how many websites currently structure the visible code, like typed in this above HTML.
.cd_tag {
text-align: left;
color: black;
height: auto;
width: 80%;
outline-color: black;
outline-width: 2px;
outline-style: dotted;
background-color: rgb(238, 238, 238);
}
/* html text(default text) */
.ht_txt {
color: black;
}
/* html tag styling */
.ht_tag {
color: red;
}
/* add < & >, encapsulting html tags */
.open::before {
font-weight: lighter;
content: "<"
}
.open::after {
font-weight: lighter;
content: ">";
}
.close::before {
font-weight: lighter;
content: "</"
}
.close::after {
font-weight: lighter;
content: ">"
}
/* a couple tab classes to make the structure easier to read */
.tab1 {
margin-left: 2rem;
}
.tab2 {
margin-left: 4rem;
}
.tab3 {
margin-left: 6rem;
}
.tab4 {
margin-left: 8rem;
}
.tab5 {
margin-left: 10rem;
}
.tab6 {
margin-left: 12rem;
}
<div class="cd_tag">
<div class="ht_tag">
<div class="open">!DOCTYPE html</div>
<div class="open tab1">html</div>
<div class="open tab2">head</div>
<div class="open tab3">style</div>
<div class="close tab3">style</div>
<div class="close tab2">head</div>
<div class="open tab2">body</div>
<div class="close tab2">body</div>
<div class="close tab1">html</div>
</div>
</div>
openclass ...?