Grouping Inline Elements with the Tag - HTML

When using CSS for text formatting, you need a method to code text with the appropriate styles. If you are coding block elements, you can use the <div> tag to delimit the block, but with smaller chunks (inline elements) you should use <span>. The <span> tag is used like any other inline tag (<b>, <i>, <tt>, and so on), surrounding the text/elements that it should affect. You use the style or class attribute to define what style should be applied. For example, both of the following paragraph samples would render the word red in red text:

Of the two methods, the use of the class attribute is preferred over using the style attribute because class avoids directly (and individually) coding the text. Instead, it references a separate style definition that can be repurposed with other text.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

HTML Topics