is it possible that move an element for the desktop only or mobile-only using xml or any other solution of it.

  • Maybe you can do this via Javascript. or Hide and show using CSS.
    – Nits
    Sep 24, 2019 at 18:01
  • Should be easy in CSS based on the viewport size. Doing it otherwise would seem to require complicated and unreliable browser detection.
    – jiheison
    Sep 24, 2019 at 19:23

3 Answers 3


You can do by CSS and Javascript both, easy you can use Simple CSS.

#content {display: block;} 

@media screen and (max-width: 768px) { 
#content {display: none;}
  • The scenario is that I need the same div content for desktop and mobile just need to change the placement of that div. Also, I don't want to duplicate the code. Sep 26, 2019 at 5:38
  • I have updated the css Sep 26, 2019 at 6:46

Not possible in XML. Display the element two times using xml, one for mobile and another one for desktop where you want

Using @sangeeta's answer you can display like

.mobile-element {display: none;} 

@media screen and (max-width: 768px) { 
    .desktop-element {display: none;}

You can do this by html and simple jQuery also:

<div class="custom" style="display:none;">Your html part </div>
   var width = $(window).width();
   if(width < 768){  //for mobile only      

Here window.width function works as below:

If you want to display for Mobile: use window width "< 768". If you want to display for Tablet/desktop devices: use window width "> 767".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.