4️⃣

4.4 Div and Span

The <div> Element

The <div> element is often used as a container for other HTML elements. The <div> element has no required attributes, but styleclass and id are common. When used together with CSS, the <div> element can be used to style blocks of content.

The <span> Element

The <span> element is often used as a container for some text. The <span> element has no required attributes, but styleclass and id are common. When used together with CSS, the <span> element can be used to style parts of the text.

CSS Properties for this Example

The background-color property sets the background color of an element. Specify the background color with a HEX value or specify the background color with an RGB value.
The color property specifies the color of text. Set the text color with a HEX value or set the text color with an RGB value.
The height and width properties are used to set the height and width of the content for an element. For now, we will be setting it as auto or with px.
notion image

Previous Section

3️⃣
4.3 Selectors
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.