#23851 closed enhancement (fixed)
Can we get some classes on the comment form output?
Reported by: | nathanrice | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Comments | Keywords: | has-patch |
Focuses: | Cc: |
Description
The comment_form()
function is quite useful, but styling it pretty much requires that you target the IDs, since the the outermost div and the form itself don't have classes.
If you're trying to stay as low on the specificity scale when writing CSS, not having classes available to target pretty much stops you cold.
I don't really care about the class names, though something descriptive and somewhat semantic would be preferable.
Anybody have thoughts?
Attachments (6)
Change History (24)
#3
@
11 years ago
Oh, I'm definitely not suggesting we remove the IDs. They're necessary, actually. I'm just suggesting adding some classes.
#4
@
11 years ago
- Component changed from Themes to Comments
- Keywords has-patch added; needs-patch removed
- Type changed from defect (bug) to enhancement
- Version set to 3.0
23851.diff would add a filterable class to the outer div, which I think should be enough. Really, the IDs alone should be enough but this would provide some flexibility.
#5
follow-up:
↓ 6
@
11 years ago
I really don't understand why we're so stingy when it comes to adding classes?
To me this is more about making it easier for child themes to override styles (IDs are almost as bad !important
when it comes to that) rather than about making elements selectable in the first place (for that IDs are enough indeed).
I'd love to be able to get rid of more IDs in Twenty Thirteen.
#6
in reply to:
↑ 5
@
11 years ago
Replying to obenland:
I really don't understand why we're so stingy when it comes to adding classes?
To me this is more about making it easier for child themes to override styles (IDs are almost as bad
!important
when it comes to that) rather than about making elements selectable in the first place (for that IDs are enough indeed).
I'd love to be able to get rid of more IDs in Twenty Thirteen.
Agree. But are these class names too generic? Like .respond?
#7
@
11 years ago
It does seem like there ought to be better class names than just duplicating the ID. Unfortunately, I can't think of any at the moment. :-)
#9
in reply to:
↑ 8
@
11 years ago
Replying to GaryJ:
.comment-respond
would be a little less generic.
The class changes in the general-template file look great.
@
11 years ago
This is a patch I prepared for #24626 that lets you specify class_form, like you can specify class_id now. It needs to be modified slightly now to include a default class to be compatible with the modified 2013 stylesheet in 23851.2 and probably should support changing the h3 and submit button classes too.
#11
@
11 years ago
Argh - I said "class_id", I meant id_form
!
Basically, I don't see why you can't specify a class for the <form>
tag, although the same goes for any other bit of the comment_form
, I suppose. wp_nav_menu
lets you specify classes (and you can hack it up nicely with walkers to target any element) but comment_form
doesn't have those options. A bit frustrating to lose that control, especially when frameworks like Bootstrap (and others) specify classes they want you to use directly on your <form>
elements. Wrapper div
s work (most of the time), but they're gratuitous markup.
#13
@
11 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In 24526:
#15
@
11 years ago
I may have arrived a few days late to this party, but could id="submit" gain class="button"?
#16
@
11 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
I'm with @chrisvanpatten we need to be able to adjust the classes... Adding them was a step in the right direction but for those template developers out there that want to be able to utilize css frame works (like bootstrap) not having access the the classes for these fields is a real bummer.
As I see it, the IDs make sense, as the function is intended for single use per-output.
While adding classes would be beneficial, given your reasoning, I'd vote for adding them without removing/replacing the ID values.
This could also be handled using a filter to add the class or wrap the form in a DIV tag containing the class.
My 2 cents. :)