An element instead of div

what element can i use instead of div?

It depends on what you are trying to do. Can you paste your code in here or at least explain what you are doing?

1 Like

im trying to put these codes in somewhere but i can’t put them in div cause ive used it before so if i do that everything will be ruin<label><input name="attribute" type="radio" value="definitely"/>definitely</label> <label><input name="attribute" type="radio" value="Maybe"/>Maybe</label> <label><input name="attribute" type="radio" value="notsure"/>not sure</label>

This looks to me like you could use a <fieldset> and <legend>.

2 Likes

can you elaborate on this? Why cant you put them in another div?

i dont want that Rectangle around it what should i do?

cause i put all of my codes in one div and that div already has a style

You can always use the googles to ask how to style fieldsets, but I’ll give you a hint, don’t you think that looks like a border?

oh right thanks for your help

ok… so, what about using classes? and then styling classes instead of styling the entire “div”? Have you done the Responsive Web Design course? It teaches you all about using id’s and classes to style your code.

ive done them but i haven’t coded for a few months and ive forgot everything:(


And if you need a block level element set to “display:block;”

Does that work?

You can always refer back to the curriculum.

Use a CSS Class to Style an Element


Just as a note, you rarely, if ever, want to apply styles to div elements using the type selector. It is a generic element (mainly used as a container) and giving all divs on the page the same style is unlikely to work on a real project (or make it very brittle).

1 Like

+1 to reading the MDN docs on elements and setting classes. Semantic html (you can use section, article, fieldset etc) is definitely encouraged in lieu of many divs.

That being said, if you want to change the style of one particular item without disrupting the styles on your main div. simple add another div around the element to change and create a class or id that you can call and style in your CSS file. hope this helps! I was reading this article today and while it’s more advanced, specificity and other rules are applicable. writing better css

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.