Title: Function new code tag to style css
Last modified: August 20, 2016

---

# Function new code tag to style css

 *  [jackitshot](https://wordpress.org/support/users/jackitshot/)
 * (@jackitshot)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/function-new-code-tag-to-style-css/)
 * Hello friends
 * i add new code tag for making new beautiful codebox, it is in function.php:
 *     ```
       function codequote( $atts, $content = null ) {
       	extract(shortcode_atts(array(
       		'float' => 'none',
       	), $atts));
          return '<style type="text/css">
              .codequote{
               ...;}
               .codequote:after{
               ...;}
               a:hover{...;}
       		</style>
       <div class="codequote ' . $float . '">' . $content . '</div>';
       }
       add_shortcode('code', 'codequote');
       ```
   
 * then it executes and shows error message “syntax error, unexpected T_CONSTANT_ENCAPSED_STRING(
   line number to <div class=”codequote…..</div>’;)”
 * can someone help me to solve it?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/function-new-code-tag-to-style-css/#post-3024002)
 * Post all of that ‘return’ statement. My guess is that you are breaking out of
   the string somewhere in there.
 * Also, ‘style’ tags are supposed to be in the ‘head’ of the document, not the 
   body. Processing this inside a shortcode is going to put it in the ‘body’. You
   really ought to be constructing an inline style attribute:
 *     ```
       <div style=" your-style-rules " > ... </div>
       ```
   
 *  Thread Starter [jackitshot](https://wordpress.org/support/users/jackitshot/)
 * (@jackitshot)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/function-new-code-tag-to-style-css/#post-3024105)
 * Thank s_ha_dum very much. good suggest.
 * I also would like to add new css style in header.php after head tag, if it’s 
   only in style.css, it may not be applied to whole html. I give Function code 
   tag up temporarily.
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/function-new-code-tag-to-style-css/#post-3024115)
 * > …if it’s only in style.css, it may not be applied to whole html.
 * That isn’t correct. Perhaps you mis-spoke? It is more the opposite. You would
   insert into header.php only if you do not want the rule to apply to the whole
   site.
 * You can use the `wp_head` filter to insert your information into in header.php,
   or, if your theme is constructed correctly, you should be able to.
 *  Thread Starter [jackitshot](https://wordpress.org/support/users/jackitshot/)
 * (@jackitshot)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/function-new-code-tag-to-style-css/#post-3024124)
 * Because new style CSS code I put in header.php is too long, so i should creat
   another *.css separated from offical style.css and add link=*.css in header.php,
   can it avoid style.css affect to new *.css which just applies to special place?
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/function-new-code-tag-to-style-css/#post-3024125)
 * I really don’t understand what you just wrote.
 * Unless you load the CSS files via a conditional of some sort, you are probably
   better off with one file vs. many. You certainly don’t want more than a few css
   files, and since many plugins load their own stylesheets that can be hard to 
   accomplish.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Function new code tag to style css’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [css](https://wordpress.org/support/topic-tag/css/)
 * [function](https://wordpress.org/support/topic-tag/function/)

 * 5 replies
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/function-new-code-tag-to-style-css/#post-3024125)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
