<code> element?

时间:2018-11-13 07:47:32

标签: html css

I noticed the neat property of text which is nested inside a code tag - it adapts to its containing div, which means it automatically breaks into a new line if the screen size is reduced, so I wanted to recreate its properties in a class and apply this class to <span> that would basically behave the same as a <code> tag. However, I didn't manage to fully mimic its behaviour, so I temporarily solved the problem regarding the styling of my product by wrapping my text with a <code> tag anyway and changing the font its size.
I've been searching all over the internet and I cannot find the source code for the styling which affects text encapsulated inside a <code> tag and would very much appreciate if someone, who has found (or created) what I couldn't, could post the css properties of a class that needs to be added to a <span> for its text to behave exactly the same as if it was inside a a <code> tag.

1 个答案:

答案 0 :(得分:0)

您可以使用以下CSS定义模拟codepre的空白行为:

.codestyle {
    white-space: pre;
}