Step 1: Add Block for an attribute on catalog_product_view.xml
<block class="Magento\Catalog\Block\Product\View\Description" name="page.main.brand" template="Magento_Catalog::product/view/brand.phtml"> <arguments> <argument name="at_call" xsi:type="string">getBrand</argument> <argument name="at_code" xsi:type="string">brand</argument> <argument name="css_class" xsi:type="string">brand</argument> <argument name="at_label" xsi:type="string">default</argument> <argument name="add_attribute" xsi:type="string">itemprop="brand"</argument> </arguments> </block>
Step 2: move it to your location
<move element="page.main.brand" destination="product.info.main" after="page.main.title"/>
Step 3 : udpate phtml file with your custom html and code
<?php /** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ // @codingStandardsIgnoreFile /** * Product description template * * @var $block \Magento\Catalog\Block\Product\View\Description */ ?> <?php $_helper = $this->helper('Magento\Catalog\Helper\Output'); $_product = $block->getProduct(); $_code = $block->getAtCode(); $_className = $block->getCssClass(); $_attributeLabel = $block->getAtLabel(); $_attributeType = $block->getAtType(); $_attributeAddAttribute = $block->getAddAttribute(); if ($_attributeLabel && $_attributeLabel == 'default') { $_attributeLabel = $_product->getResource()->getAttribute($_code)->getFrontendLabel(); } $_attributeValue =$_product->getResource()->getAttribute($_code)->getFrontend()->getValue($_product); ?> <?php if ($_attributeValue): ?> <div class="product attibute <?php echo $_className?>"> <?php /*?><?php if ($_attributeLabel != 'none'): ?><strong class="type"><?php echo $_attributeLabel?></strong><?php endif; ?><?php */?> <div class="value" <?php echo $_attributeAddAttribute;?>><?php echo $_attributeValue; ?></div> </div> <?php endif; ?>