html - Is it OK to use inside ? -


Is it okay to use the "div" tag inside the "code" tag? I am using Netbeans 8.0.1 to write some HTML pages. And at some point I was using "div" inside "code". You can see a part of your code

Netbense gives me the following error

Elements The element "div" in this context is not allowed as a child of the "code". / Strong>

The result is what I want but the error bothers me, is it a problem anyway? Is there a way to get the same results without error?

Code from jsfiddle:

  & lt; div class = "codeDiv" & gt; & Lt; Pre & gt; & Lt; code class = "black" & gt; State & lt; Sub & gt; 0 & lt; / Sub> & Lt; Div class = "back-red codebox margin" & gt; If (XPRT  1  gt;) & lt; div class = "back-green codebox margin" & gt; If (XPropRT; LT; sub-gt; 2 & lt; / sub & gt;) {stat & lt; Sub & gt; 1 & lt; / Sub> State & LT; Sub & gt; 2 & lt; / Sub & gt; } And & lt; Div class = "back-blue codebox margin" & gt; If (XPropATT; LTTE; 3  gt;) {stat & lt; Sub & gt; 4 & lt; / Sub> State & LT; Sub & gt; 5 & ​​lt; / Sub & gt; } And state & lt; Sub & gt; 6 & lt; / Sub> & Lt; / Div & gt; & Lt; / Div & gt; And state & lt; Sub & gt; 7 & lt; / Sub> & Lt; / Div & gt; State & LT; Sub & gt; 8 & lt; / Sub & gt; & Lt; / Code & gt; & Lt; / Pre & gt; & Lt; / Div & gt;    

If you want to mark your code with code > Element, but if you want a specific presentation style, use elements like div to set the elements of elements, and then and lt; Code & gt; for your html, it will:

  & lt; Div class = "codeDiv black" & gt; & Lt; Code & gt; State & LT; Sub & gt; 0 to & lt; / Sub & gt; & Lt; / Code & gt; & Lt; Div class = "back-red codebox margin" & gt; & Lt; Code & gt; If (XPRT  1  gt;) & lt; / Code & gt; & Lt; Div class = "back-green codebox margin" & gt; & Lt; Code & gt; If (excrotti; lt; sub-gt; 2 & lt; / sub & gt;) {stat & lt; Sub & gt; 1 & lt; / sub & gt; State & LT; Sub & gt; 2 & lt; / Sub & gt; } And & lt; / Code & gt; & Lt; Div class = "back-blue codebox margin" & gt; & Lt; Code & gt; If (XPropATT; LTTE; 3 ) {stat & lt; Sub & gt; 4 & lt; / Sub> State & LT; Sub & gt; 5 & ​​lt; / Sub & gt; } And state & lt; Sub & gt; 6 & lt; / Sub> & Lt; / code & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Code & gt; Other states & lt; Sub & gt; 7 & lt; / sub & gt; & Lt; / Code & gt; & Lt; / Div & gt; & Lt; Code & gt; State & LT; Sub & gt; 8 & lt; / Sub & gt; & Lt; / Code & gt; & Lt; / Div & gt;   

NB: I did not sign the & lt; Pre & gt; tag has been deleted!

You can set spaces to protect using the CSS declaration code {White-space: east; } and set your font in a suitable monospace font.

  code {white-space: pre; Font: 1 AM / 1.5 Menlo, Console, 'Dejaav Sense Mono', Monaco, Monospace; / * Or whatever * /}   

.

Lift; Code & gt; There is an inline element to mark the spanning of text within the block , & lt; P & gt; , and similar level elements. While most browsers would happily introduce your original HTML, this syntax would be incorrect.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -