Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Comments on HTML tags versus CSS classes: is one preferred over the other for the same styling?

Post

HTML tags versus CSS classes: is one preferred over the other for the same styling?

+6
−0

We publish documentation online using HTML. For things like fixed parameter names and other code literals, we use <code> tags. My question is about styling these in tables.

On our reference pages, we list parameters in tables -- parameter name in the first column, description in another. I have been using <code> tags there (inside the <td>), same as in running text -- it's a semantic tag of sorts, so this makes sense to me. But HTML wasn't my first markup language, and maybe that's a habit I picked up from SGML before it.

Recently I have discovered that someone else on the team is instead formatting those parameter cells as <td class="code">, and apparently we have CSS that supports that. (We're using a tool; we didn't write all our CSS from scratch.) Assuming that the cell contains one parameter and nothing else (like a list of parameters or parenthetical notes), so it looks the same to the reader, is there a reason to prefer one approach over the other? Both can be styled; is one more efficient or versatile than the other? I'd like us to pick one approach and all do it, to make maintenance easier, and I'm wondering if this is "six of one, half dozen of the other" or if there are good reasons for one over the other.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General Comments (2 comments)
General Comments
deleted user wrote over 3 years ago

.code is different from code. .code is for code class. And, code is for `. As far as I remember, I haven’t seen .code in CSS. So, if you want to use code as class than, some changes are required in CSS

Monica Cellio‭ wrote over 3 years ago

We apparently have that CSS already. My point is that we have two different ways of producing the same formatting in the output, the code tag and the code CSS class, and I'd like to know if there are reasons to prefer one over the other. I want us to have one consistent way of doing it, not two depending on who last edited the topic.