• Truth

    (@truth)


    I wanted to add a style to some of my codes so I have this

    <code class="box">

    but after I save the page, it becomes <code> and the class is not saved so I can’t have the style for it. Any idea how to fix it?

    Thank you 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • ladydelaluna

    (@ladydelaluna)

    you might need to create a div for it in your stylesheet, and call it something other than “code” such as “snippet” or something… then style the div inside the css, so that all you have to do is use <div id="snippet"> when entering code into your posts or pages…

    <code> will default to wordpress’s way of showing code…

    There may be another way to change the default way WP shows code, but this is my offer for a solution 😉

    Thread Starter Truth

    (@truth)

    Ohhhh. okok. thanks 🙂

    I’m using the <blockquote> tag outside the <code> tag now and I would like to use the blockquote tag for something else hence using a class for the code. I’ll try out that solution if no one has a better idea on how to go about showing my class for the code tag. Thank you 🙂

    Karrde

    (@karrde)

    The <code> tag isn’t HTML, so you can’t give it a class as you could if it were, say, a <div>. You’ll have to use the <div> method unless you’re comfortable with hacking WordPress itself to modify its display method (which seems a waste of time when you could just do it via <div>).

    Thread Starter Truth

    (@truth)

    @karrde: Can I use the blockquote tag with a class=”code” instead?

    Karrde

    (@karrde)

    Uhm, I’m not sure. Try it and see 🙂

    I’m not sure on how WordPress parses the tags from its editor – I’ve never really looked into it terribly much.

    ladydelaluna

    (@ladydelaluna)

    if all you’re wanting to do is have the “code” show up in blocktext format, then yes, you can do

    <blockquote><code>
    blahblahblah
    </code></blockquote>

    I THINK…

    Are you trying to have more than one style for code? you can simply style code in your style sheet, much like blockquote.

    code {style: here}

    just note there’s no . or # for it.

    Thread Starter Truth

    (@truth)

    Yupz, for the short codes, I just want to wrap them in the usual code tag for some, I wanted them to add a style to them like my blockquote.. I think I get it now. Thanks for your help 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘<code class=”box”> disappear when page saved?’ is closed to new replies.