Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialIan Johnson
2,749 PointsSimple definitions of DIV element and CLASS attributes - for a simple mind.
Apologies in advance for this being a simple Q; still, please correct me if I'm way off with my simplified definitions of the following:
DIV = element used to divide/group parts of the html document (e.g. into boxes/tables/etc.), similar to drawing a box around a section of writing in some hand-written notes.
CLASS = attribute that acts as a sort of bookmark for certain elements/groups of elements within the html document, so that they can be specified and targeted in CSS. CLASS can be used to group the same elements (e.g. all the <a> elements within the html doc), or it can be used to single out specific elements (e.g. only the h1 element) for pin-pointing in CSS.
Many thanks.
1 Answer
jb30
44,807 PointsThe description of divs is mostly accurate. If you want to create a table for data, there is an html tag table
. If you want a table for layout, then divs would be useful.
Classes do not need to have only one element tag. You can have any type of element in the the same class.
If you want to select all the elements of the same type, you don't need to create a class. You can use their tag name. For example, to select all the paragraphs using css,
p {
}
Ian Johnson
2,749 PointsIan Johnson
2,749 PointsAh! I get what you mean! Perfect, thank you for clarifying/explaining further jb30