SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,873
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)

    Adding attributes to <body> on master

    Hey guys

    Im using a master page.. main.master. Now from a normal page that uses the master i need to add an attribute to the Master pages body tag.

    Please help me get this right.

    Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <body runat="server" id="Body">
    ...
    </body>

    then expose methods to manipulate the of the master page.
    Finally address it user the Master property of the content page.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,785
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    A properly designed web page written to modern standards should never have any attributes on the body tag as there are better ways of attaching all of the things that can be put there.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Enthusiast scarecrow-rye's Avatar
    Join Date
    Nov 2005
    Location
    Cornwall, UK
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would disagree. There are times when you simply need to add attributes to the BODY tag - e.g. when you're adding page specific styling via CSS or coding for backwards compatibility.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,785
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    As there is only ever one body tag you don't need to add anything to the tag itself. You can apply any styling using:

    <style>body {...}</style>

    or

    document.getElementsByTagName('body')[0].style = ...
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Enthusiast scarecrow-rye's Avatar
    Join Date
    Nov 2005
    Location
    Cornwall, UK
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I quite often apply ID or CLASS attributes to the BODY tag to help identify the current page. For example...

    <body id="news">

    With this I can then use CSS to style the page and navigation menus on a section to section basis.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •