• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Hi,

I am an IT teacher currently preparing a set of teaching notes on how to mark up web pages that will be accessible to the blind and those with cognitive impairments. The notes themselves will also be web pages.
Up to now I have used an <ol>/<ol> nested inside a <pre> element. This method has worked perfectly for a number of years but now my HTML validator tells me one cannot embed an ordered list inside a <pre> element. Hence I am going to Code Forum for help.
 

cbreemer

King Coder
I'm surprised to hear lists work inside a <pre></pre> block. I don't think it was ever supposed to, because the documentation states
The text will be displayed exactly as written in the HTML source code.
which seems to imply that any inner HTML code will be displayed as-is, tags and all.
Your construction still works, at least in Chrome, but I guess it could break in the future. The validator is right to warn you about it.
 
Last edited:

ezmartech

Coder
The <pre> element is for preformatted text, so you can't put additional formatting tags inside it. By the look of things, you would be better off using <div> elements instead. The nesting of the lists can be fixed by keeping the nested <ol> elements inside the parent <li> elements
 

Malcolm

Administrator
Administrator
Staff Team
Welcome to Code Forum! :)

As you may have noticed already, Code Forum is always ready to help! Did you end up getting this resolved?
 

Krygore

King Coder
Alternatively, you can also use a <ul> tag to create an unordered list rather than an <ol> tag (bullet points or squares instead of numbers)
 
Top