This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Suggestion in section 4.5 Grouping Content Problem: I'm building webpages that give lessons in C#. They are pages with multiple blocks of code between paragraphs explaining the code. The code blocks are enclosed by PRE and CODE tags Example: <pre class="c-sharp"><code> public class MyException : ApplicationException { private ExceptionLevel exceptionLevel; private LogLevel logLevel; private Exception myException; private string exceptionMessage; public string ExceptionMessage { get { return this.exceptionMessage; } set { this.exceptionMessage = value; } } public MyException() { } public MyException(ExceptionLevel exceptionLevel, LogLevel logLevel, Exception exception, string exceptionMessage) { this.exceptionLevel = exceptionLevel; this.logLevel = logLevel; this.myException = exception; this.exceptionMessage = exceptionMessage; } } </code></pre> Because these pages are for students learning the programming language, syntax highlighting is necessary for the pages to be readable. There is far too much content to go through and add all the color formatting with span tags, so I have decided to use a syntax highlighting script. Thus far, the only syntax highlighting script I have found requires the PRE tag to have a class of the programming language that is enclosed by the CODE tag. This is backwards - the Code tag should describe the programming language enclosed within, not the PRE tag. Plus, there is code smell in the source of my html document. Well over half of the code tags are enclosed in pre tags simply because I need to display a block of pre-formatted code. This is a very common need, probably more common than displaying a single line of code. Solution: <codeblock> Codeblock would be an element used to enclose a block of pre-formatted code without having to nest a code element within a pre element. Old: <pre class="c-sharp"><code> New: <codeblock class="c-sharp">
Even if <codeblock> were added, your syntax highlighters still wouldn't work until they were updated to look at <codeblock> instead of <pre>. It seems easier to just update them to look at <code> instead - that way we don't need to change the spec and browsers as well as syntax highlighting scripts.
(In reply to comment #1) > Even if <codeblock> were added, your syntax highlighters still wouldn't work > until they were updated to look at <codeblock> instead of <pre>. It seems > easier to just update them to look at <code> instead - that way we don't need > to change the spec and browsers as well as syntax highlighting scripts. Thanks for the suggestion Tab. That's probably what I'll end up doing.
Closing per comment 2. Reopen if you still want the editor to consider the proposal.
mass-move component to LC1