How to use Inline Styles In CSS
The basic method is to set the width and height of a <span>
element using inline styles directly within the HTML tag.
In this example, the style attribute is used to set the width to 200px and the height to 100px. Additionally, display: inline-block; is applied to allow the <span> to have width and height properties.
Example:
HTML
<!DOCTYPE html> < html lang = "en" > < head > < title > Set Width and Height of Span with Inline Styles </ title > </ head > < body > < span style=" width: 200px; height: 100px; display: inline-block; background-color: rgb(6, 104, 42);"> w3wiki </ span > </ body > </ html > |
Output:
How to Set Width and Height of Span Element using CSS ?
The <span>
tag is used to apply styles or scripting to a specific part of text within a larger block of content. The <span>
tag is an inline element, you may encounter scenarios where setting its width and height becomes necessary. This article explores various approaches to set the width and height of a <span>
element using CSS.