Why does HTML5 recommend putting the code element inside pre?

前端 未结 4 928
夕颜
夕颜 2020-12-04 14:27

The HTML5 documentation recommends putting the code element inside the pre element, but I don\'t understand how this is better or more semantic tha

4条回答
  •  悲哀的现实
    2020-12-04 14:38

    To represent a block of computer code, the pre element can be used with a code element;

    To represent a block of computer output the pre element can be used with a samp element.

     for block code that must not wrap.
    Use  for inline code that can wrap.

    Line breaks and white spaces in the text enclosed within the

     tags is maintained as it is in the html document when displays on the browser.Browsers normally render 
     text in a fixed-pitched font, with whitespace.

提交回复
热议问题