我讀Wordpress's coding standards垂直間距的Wordpress HTML編碼標準(HTML標籤之間的空白)?
對我來說,唯一令人困惑的部分,例如HTML代碼之間的垂直間距:
默認WordPress主題3.03:
的sidebar.php:
<li id="search" class="widget-container widget_search">
<?php get_search_form(); ?>
</li>
<li id="archives" class="widget-container">
<h3 class="widget-title"><?php _e('Archives', 'twentyten'); ?></h3>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>
</li>
(這裏是兩個<li>
標籤之間的空格)
的header.php
<div id="masthead">
<div id="branding" role="banner">
<?php $heading_tag = (is_home() || is_front_page()) ? 'h1' : 'div'; ?>
<<?php echo $heading_tag; ?> id="site-title">
(在這裏,有div
標籤之間沒有空格)
的header.php(線79 ...):
</div><!-- #branding -->
<div id="access" role="navigation">
<?php /* Allow screen readers/text browsers to skip the navigation menu and get right to the good stuff */ ?>
<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e('Skip to content', 'twentyten'); ?>"><?php _e('Skip to content', 'twentyten'); ?></a></div>
<?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?>
<?php wp_nav_menu(array('container_class' => 'menu-header', 'theme_location' => 'primary')); ?>
</div><!-- #access -->
</div><!-- #masthead -->
</div><!-- #header -->
<div id="main">
(這裏,之間有空間3 <div>
標籤
什麼是垂直間距的編碼標準(我不認爲它是隨機的)?
感謝您的好例子。在這種情況下,我想知道如何正確嵌套HTML標籤(元素之間的垂直空間)。 – alexchenco 2010-12-20 09:42:00
這實際上取決於你正在處理的代碼,但通常只有一行空白(我覺得)可以用來從HTML代碼塊中分離出PHP代碼塊(比如當你執行一些數據迭代時爲每次迭代輸出HTML)。 – t31os 2010-12-20 10:12:27
這就是說它取決於代碼的樣子,我將通過PHP和HTML的混合添加上面的另一個示例,並向您展示我將如何親自格式化它。 – t31os 2010-12-20 10:18:13