1. 9

    How do you know which styles to use?

    Like, say:

    .tabbrowser-tab[selected] .tab-background {
        background: #75cc00 !important;

    How do you find out that you need to use those specific class names?

    I tried looking this up, but came back rather empty-handed. Loads of examples abound, but it’s never very clear to me what classes apply to what exactly and how people figure out what the class names are in the first place.

    1. 21
      1. 3

        Aha, brilliant! Thank you

        1. 3

          Thanks! I’ve cited you in the post, as my changes only involved editing existing styles from other people.

      1. 2


        Yeah, it does:

        The querySelector() method of the Element interface returns the first element that is a descendant of the element on which it is invoked that matches the specified group of selectors.


        Easy example. Go here: https://example.com. Result:

        NodeList []
        1. 4

          In a certain sense, it does, but not in the way you might expect it to.

          Suppose you have the following markup:

          <div class="a">
              <div class="b">
                  <div class="c"></div>

          The result of b.querySelector('.a .c') is not document.querySelector('.b .a .c'), which would be null. Instead, it returns document.querySelectorAll('.a .c').filter(e => b.contains(e))[0] which is c.

          So it is scoped in the sense that you’ll only get back elements that are children of the element you’re calling querySelectorAll on, but the CSS query itself is not scoped to the element.

          1. 1

            Yeah, this tripped me up earlier in the year. I wrote a dom library for the D language and got a bug report saying the results were inconsistent with javascript and I was like “wtf”…. then saw this in the spec. (In fact, with mine, there’s just an implicit :scope at the start of the string, so you can do querySelector("> div"); to get like the immediate child.)

            I find my behavior more useful though so I haven’t actually “fixed” it… I actually don’t understand why javascript did it this way. It kinda smells like a bug that they regretted but couldn’t fix without unknowable compatibility woes, so they added :scope to work around it.

            1. 1

              Wow that is horrible. With the current page we are on, this fails:


              but this works:

              document.querySelector('.story').querySelector('.stories .story_liner');
            2. 1

              I don’t know what to tell you, the code is there, and when run, you can see for yourself… https://jsfiddle.net/tyg2fdmp/

            1. 5

              The text macros I get, this is clearly a refined system and it’s impressive but I get it. I completely do not get how he’s producing those diagrams in realtime in the middle of a lecture though, so this blog post is a cliffhanger :-)

              1. 3

                I really want to see how the diagrams happen. My thoughts: diagrams on a sketchpad that are later imported (or imported with a script??).

                I used to take notes in LaTeX for 2 courses, for diagrams I would draw them in my notebook and then make diagrams and graphs after class. I stopped doing it because it got to a point where I was trying to fix a latex error and I would ignore the content. I think what would’ve worked best for me would be to take notes in LaTeX during class, but only try to compile it and fix errors after class.

                1. 2

                  Have a look here!

                  1. 1

                    You have a really awesome workflow. Thanks for sharing!

                2. 2

                  I just published the follow-up blog post here!

                  1. 1

                    I was wondering how you did it, if there was a bit of a cheat maybe, and I’m delighted to see that the answer is “streamlining and lots of practise with inkscape”! This is inspirational stuff, keep it up :-)

                  2. 1

                    I think the answer is mentioned but the setup isn’t described. He’s using SyncTeX with his PDF viewer Zathura sitting next to his terminal that’s running Vim. I agree, it’s a super slick setup to watch in real time.

                    1. 2

                      Re-reading you comment, I see that you meant the graphical diagrams and not just the LaTeX generation…that would be interesting to see.