0

Im trying to understand some HTML/ CSS elements for web scraping. I encountered this tag

<span class="lister-item-index unbold text-primary"> </span>

May I know whether "lister-item-index unbold text-primary" under class are options/ properties for the span tag or it is just a name for the class?

Rob
  • 14,746
  • 28
  • 47
  • 65
Empowered
  • 7
  • 3
  • they are 3 different css classes applied to that span element (*space being the separator*). It would be the same if it were `unbold lister-item-index text-primary"` or `text-primary lister-item-index unbold"` etc.. – Gabriele Petrioli Oct 19 '21 at 08:02

1 Answers1

2

span is just a literal kind of html tag. nothing exotic here. lister-item-index unbold text-primary are css classes. They are used to add some style to the tag.

More on the class attribute:

The class global attribute is a space-separated list of the case-sensitive classes of the element. Classes allow CSS and Javascript to select and access specific elements via the class selectors or functions like the DOM method document.getElementsByClassName.

mdn

More on the class selector:

In an HTML document, CSS class selectors match an element based on the contents of the element's class attribute. The class attribute is defined as a space-separated list of items, and one of those items must match exactly the class name given in the selector.

mdn

.blue { color: blue; }

.text-primary { color: green; }

.red-border { border-bottom: 1px red solid; }
<span>test</span>
<br><br>
<span class="blue red-border">test</span>
<br><br>
<span class="blue">test</span>
<br><br>
<span class="text-primary red-border">test</span>

another example:

.red {
  color: #f33;
}

.yellow-bg {
  background: #ffa;
}

.fancy {
  font-weight: bold;
  text-shadow: 4px 4px 3px #77f;
}
<p class="red">This paragraph has red text.</p>
<p class="red yellow-bg">This paragraph has red text and a yellow background.</p>
<p class="red fancy">This paragraph has red text and "fancy" styling.</p>
<p>This is just a regular paragraph.</p>
aloisdg
  • 22,270
  • 6
  • 85
  • 105
  • @Empowered if this is helpful to you, it can be too to others. Dont forget to upvote and mark it as solved. :) – aloisdg Oct 19 '21 at 09:21
  • Note that the [
    ](https://html.spec.whatwg.org/dev/text-level-semantics.html#the-br-element) tag does not use and does not need a closing slash and never has in any HTML specification.
    – Rob Oct 19 '21 at 09:24
  • @Rob I started with xhtml and I guess that I keep it like this since x) (a Q&A about br: https://stackoverflow.com/questions/1946426/html-5-is-it-br-br-or-br) – aloisdg Oct 19 '21 at 09:31
  • I don't need any explanation. I've been doing this for 20 years Why people put that slash there is beyond me. You would think someone would give the actual specification an occasional glance rather than waste time with this pointless excuse. – Rob Oct 19 '21 at 09:34
  • @Rob "I don't need any exaplanation", The link was not strictly for you but to anyone looking for more. The MDN says something about `
    `: "In XHTML documents, write this element as
    ". This is a minor issue out of the scope of this question.
    – aloisdg Oct 19 '21 at 09:54
  • This is HTML, not XHTML which is a XML application. Talking about it only confuses people. And there are a LOT of confused people on SO. – Rob Oct 19 '21 at 10:06