Pratik Gupta
Pratik Gupta

Reputation: 67

How to do Nesting of html elements in cakePHP 3 syntax?

I want to know that how to write the below given html code in cakePHP 3 syntax :-

<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
   <span class="sr-only">Toggle navigation</span>
</a>

Upvotes: 0

Views: 208

Answers (1)

arilia
arilia

Reputation: 9398

you can simply put the span tag inside the html link this way

<?= $this->Html->link(
    '<span class="sr-only">Toggle navigation</span>',
    '#', [
        'class' => "sidebar-toggle",
        'data-toggle' => "push-menu",
        'role' => "button",
        'escape' => false
    ]); ?>

or you can use the tag method to create the span tag

<?= $this->Html->link(
    $this->Html->tag('span', 'Toggle navigation', ['class'=>"sr-only"]),
    '#', [
        'class' => "sidebar-toggle",
        'data-toggle' => "push-menu",
        'role' => "button",
        'escape' => false
    ]); ?>

Upvotes: 1

Related Questions