Title: Best markup for WordPress?
Last modified: May 3, 2021

---

# Best markup for WordPress?

 *  Resolved [Nic727](https://wordpress.org/support/users/nic727/)
 * (@nic727)
 * [5 years ago](https://wordpress.org/support/topic/best-markup-for-wordpress/)
 * Hi,
 * I’m a newbie developing my own theme.
 * I currently hard-coded my page title as <h1>, but I would like to know what’s
   the best way to code in WordPress between :
 * `<h1><?php echo the_title(); ?></h1>`
 * or
 * `<?php the_title( '<h1>', '</h1>' ); ?>`
 * I guess it’s doing the same thing at the end, but what’s the most used way by
   devs?
 * Thank you

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

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years ago](https://wordpress.org/support/topic/best-markup-for-wordpress/#post-14390621)
 * Well, since `the_title()` function echoes its result, your first sample is no
   good.
    It doesn’t really matter what others are doing. You can write it however
   you want. For instance, my theme uses a function that filters for attributes,
   so I pass all my HTML through that. If you don’t want to do that, you can at 
   least consider that core functions are usually filtered, so you give child themes
   and plugins a chance to modify things if you pass parameters through functions
   with filters.
 *  Thread Starter [Nic727](https://wordpress.org/support/users/nic727/)
 * (@nic727)
 * [5 years ago](https://wordpress.org/support/topic/best-markup-for-wordpress/#post-14390632)
 * I want to add dynamic page title in this code
 *     ```
       <section class="page-header"> 
           <div class="featured-image-container"> 
               <div class="featured-image" style="<?php if($page_image) echo 'background-image:url(\''.$page_image[0].'\')' ?>"></div>                 
               <div class="img-overlay"></div>                 
               <div class="page-title"> 
                   <h1>TITLE HERE</h1> 
               </div>                 
           </div>             
       </section>   
       ```
   
 * I know for category.php it’s `<?php echo single_cat_title(); ?>`, so I thought
   that the_title() was doing the same thing for posts and pages…
    -  This reply was modified 5 years ago by [Nic727](https://wordpress.org/support/users/nic727/).
    -  This reply was modified 5 years ago by [Nic727](https://wordpress.org/support/users/nic727/).
 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [5 years ago](https://wordpress.org/support/topic/best-markup-for-wordpress/#post-14391463)
 * Suggest that you download and review the available themes and let us know what
   you find.
    The point of having your text and page structures subject to filters
   and hooks is well made.

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

The topic ‘Best markup for WordPress?’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/best-markup-for-wordpress/#post-14391463)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
