3.8 span and div Elements
So far, we’ve discussed different types of selectors—type selectors, the universal selector, class selectors, and ID selectors. No matter which selector you choose, you can apply it only if there’s an element in the web page body that matches it. But suppose you want to apply CSS to text that doesn’t coincide with any of the HTML5 elements. What should you do?
If you want to apply CSS to text that doesn’t coincide with any of the HTML5 elements, put the text in a span element or a div element. If you want the affected text embedded within surrounding text, use span (since span is a phrasing element). On the other hand, if you want the text to span the width of its enclosing container, use div (since div is a block ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access