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

Post History

80%
+6 −0
Q&A HTML tags versus CSS classes: is one preferred over the other for the same styling?

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 referenc...

2 answers  ·  posted 3y ago by Monica Cellio‭  ·  last activity 2y ago by Canina‭

#1: Initial revision by user avatar Monica Cellio‭ · 2021-08-19T00:01:06Z (about 3 years ago)
HTML tags versus CSS classes: is one preferred over the other for the same styling?
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.