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 trial

WordPress

What do these div' classes mentioned below do?

What does div class=wrapper mean? Div class=content block? Div class=profile-description Divclass= profile-image?

2 Answers

Dan James
Dan James
2,709 Points

Classes and IDs can be assigned to HTML elements like divs to allow them to be targeted with CSS for styling, and also by other front-end languages like JavaScript, and JavaScript libraries like JQuery.

If we were to write an HTML page with no associated CSS (or JS), any classes and/or IDs we assigned would do nothing. However, HTML is rarely written to work in isolation. The Wordpress core, themes, and plugins all generate HTML pages which will typically have some CSS to go with them. The developers will probably have created style rules in the CSS that goes with their HTML (which is actually generated by PHP in the case of Wordpress) which changes the way the page content appears in the browser. They may also have created sensible classes and IDs for elements, but not styled them, in order that other developers may come along and style their content.

So the classes you refer to are generated by Wordpress, most likely by the theme.

<div class="wrapper"></div>

This class is most likely assigned to the div element which contains the page content or a large section of content.

<div class="profile-image"></div>

This class probably wraps the img element for a user's avatar image, and so on.

If you learn how to use CSS with Wordpress, you can assign style rules to these elements and classes to change the way those elements are displayed on the page. You could also learn how to use the different browsers' developer tools to inspect the HTML and CSS of any page you view. I'm sure several Treehouse courses cover how to do these things in great detail!

Andi Wilkinson
Andi Wilkinson
26,822 Points

the div is basically dividing the page into sections, - the class is allowing you to define a style - so you may want to apply a different text size for profile for example