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

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

In my book, Structured Writing: Rhetoric and Process, I make a distinction between three domains of markup, the subject, document, and presentation domain. CSS is a presentation domain language. HT...

posted 3y ago by Mark Baker‭  ·  edited 3y ago by Canina‭

Answer
#2: Post edited by user avatar Canina‭ · 2021-08-21T12:55:19Z (over 3 years ago)
  • In my book, [Structured Writing: Rhetoric and Process](https://xmlpress.net/publications/structured-writing/), I make a distinction between three domains of markup, the subject, document, and presentation domain. CSS is a presentation domain language. HTML was originally a mess of document and presentation domain with a the odd bit of subject domain thrown in. The intention now is to make it more or less a pure document domain language, let XML define subject-domain languages, and use CSS as the presentation domain language.
  • `<code>` is a funny tag, because it has meaning in all three domains. But in this context it makes the most sense to treat it as a document domain tag. In other words, it says that a certain piece of text is to be treated as code, but does not say how it is to presented.
  • Thus using `<code>` in the HTML and then styling it appropriately in CSS maintains these distinctions.
  • Complexity can arise if you have different types of code that you want to format differently. This is really getting into the subject domain, but unless you want to go full XML, you will probably want to handle this in the HTML. This is where the sytle attribute can come in handy, allowing you to say `<code class="visual basic">`.
  • But I see no virtue in using `<td class="code">`, which is really confusing two things. The table sell is not code. The content of the cell is code, so it is the content that should be tagged as code.
  • Good markup practice in every domain is too mark something up as what it actually is. Markup that achieves the desired effect while mislabeling things is apt to cause problems down the road. And that is the formal argument too back up your preference, which is absolutely correct.
  • In my book, [Structured Writing: Rhetoric and Process](https://xmlpress.net/publications/structured-writing/), I make a distinction between three domains of markup, the subject, document, and presentation domain. CSS is a presentation domain language. HTML was originally a mess of document and presentation domain with a the odd bit of subject domain thrown in. The intention now is to make it more or less a pure document domain language, let XML define subject-domain languages, and use CSS as the presentation domain language.
  • `<code>` is a funny tag, because it has meaning in all three domains. But in this context it makes the most sense to treat it as a document domain tag. In other words, it says that a certain piece of text is to be treated as code, but does not say how it is to presented.
  • Thus using `<code>` in the HTML and then styling it appropriately in CSS maintains these distinctions.
  • Complexity can arise if you have different types of code that you want to format differently. This is really getting into the subject domain, but unless you want to go full XML, you will probably want to handle this in the HTML. This is where the sytle attribute can come in handy, allowing you to say `<code class="visual basic">`.
  • But I see no virtue in using `<td class="code">`, which is really confusing two things. The table cell is not code. The content of the cell is code, so it is the content that should be tagged as code.
  • Good markup practice in every domain is to mark something up as what it actually is. Markup that achieves the desired effect while mislabeling things is apt to cause problems down the road. And that is the formal argument too back up your preference, which is absolutely correct.
#1: Initial revision by user avatar Mark Baker‭ · 2021-08-20T22:35:03Z (over 3 years ago)
In my book, [Structured Writing: Rhetoric and Process](https://xmlpress.net/publications/structured-writing/), I make a distinction between three domains of markup, the subject, document, and presentation domain. CSS is a presentation domain language. HTML was originally a mess of document and presentation domain with a the odd bit of subject domain thrown in. The intention now is to make it more or less a pure document domain language, let XML define subject-domain languages, and use CSS as the presentation domain language. 

`<code>` is a funny tag, because it has meaning in all three domains. But in this context it makes the most sense to treat it as a document domain tag. In other words, it says that a certain piece of text is to be treated as code, but does not say how it is to presented. 

Thus using `<code>` in the HTML and then styling it appropriately in CSS maintains these distinctions. 

Complexity can arise if you have different types of code that you want to format differently. This is really getting into the subject domain, but unless you want to go full XML, you will probably want to handle this in the HTML. This is where the sytle attribute can come in handy, allowing you to say `<code class="visual basic">`. 

But I see no virtue in using `<td class="code">`, which is really confusing two things. The table sell is not code. The content of the cell is code, so it is the content that should be tagged as code. 

Good markup practice in every domain is too mark something up as what it actually is. Markup that achieves the desired effect while mislabeling things is apt to cause problems down the road. And that is the formal argument too back up your preference, which is absolutely correct.